mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 04:52:39 +02:00
Fixed heap
This commit is contained in:
parent
3b8da4cddc
commit
d8eb347247
@ -9,7 +9,7 @@ _start:
|
|||||||
|
|
||||||
startup:
|
startup:
|
||||||
// get aslr base
|
// get aslr base
|
||||||
sub x30, x30, #4
|
sub x28, x30, #4
|
||||||
|
|
||||||
// clear .bss
|
// clear .bss
|
||||||
ldr x0, =__bss_start__
|
ldr x0, =__bss_start__
|
||||||
@ -18,7 +18,7 @@ startup:
|
|||||||
add x1, x1, #7 // round up to 8
|
add x1, x1, #7 // round up to 8
|
||||||
bic x1, x1, #7
|
bic x1, x1, #7
|
||||||
mov x2, #0
|
mov x2, #0
|
||||||
add x0, x0, x30 // relocate ptr
|
add x0, x0, x28 // relocate ptr
|
||||||
|
|
||||||
bss_loop:
|
bss_loop:
|
||||||
str x2, [x0], #8
|
str x2, [x0], #8
|
||||||
@ -31,30 +31,24 @@ bss_loop:
|
|||||||
sub x1, x1, x0 // calculate size
|
sub x1, x1, x0 // calculate size
|
||||||
add x1, x1, #7 // round up to 8
|
add x1, x1, #7 // round up to 8
|
||||||
bic x1, x1, #7
|
bic x1, x1, #7
|
||||||
add x0, x0, x30 // relocate ptr
|
add x0, x0, x28 // relocate ptr
|
||||||
|
|
||||||
got_loop:
|
got_loop:
|
||||||
ldr x3, [x0]
|
ldr x2, [x0]
|
||||||
add x3, x3, x30
|
add x2, x2, x28
|
||||||
str x3, [x0], #8
|
str x2, [x0], #8
|
||||||
subs x1, x1, #8
|
subs x1, x1, #8
|
||||||
bne got_loop
|
bne got_loop
|
||||||
|
|
||||||
|
ldr x3, =heapSetup
|
||||||
// setup heap
|
add x3, x3, x28
|
||||||
ldr x1, =HEAP_SIZE
|
|
||||||
svc 1 // check retval?
|
|
||||||
mov x0, x1
|
|
||||||
ldr x1, =HEAP_SIZE
|
|
||||||
ldr x3, =heapInit
|
|
||||||
add x3, x3, x30
|
|
||||||
blr x3
|
blr x3
|
||||||
|
|
||||||
mov x0, #0 // argc
|
mov x0, #0 // argc
|
||||||
mov x1, #0 // argv
|
mov x1, #0 // argv
|
||||||
|
|
||||||
ldr x3, =main
|
ldr x3, =main
|
||||||
add x3, x3, x30
|
add x3, x3, x28
|
||||||
blr x3
|
blr x3
|
||||||
|
|
||||||
_sysexit:
|
_sysexit:
|
||||||
|
@ -31,6 +31,11 @@ void heapInit(void* base, size_t size) {
|
|||||||
g_LastFree.Prev = hdr;
|
g_LastFree.Prev = hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void heapSetup() {
|
||||||
|
static u8 g_Heap[0x20000];
|
||||||
|
heapInit(g_Heap, sizeof(g_Heap));
|
||||||
|
}
|
||||||
|
|
||||||
void* heapAllocPages(size_t size) {
|
void* heapAllocPages(size_t size) {
|
||||||
void* ptr = heapAlloc(size + 0x1000);
|
void* ptr = heapAlloc(size + 0x1000);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user