From 66523edaae3947079d2d79c9cf1d2b306049165c Mon Sep 17 00:00:00 2001 From: fincs Date: Wed, 20 Aug 2014 23:32:09 +0200 Subject: [PATCH] initSystem.c: revise heap code, disable global destructors due to crashes --- libctru/source/initSystem.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libctru/source/initSystem.c b/libctru/source/initSystem.c index 6176b34..0e89d63 100644 --- a/libctru/source/initSystem.c +++ b/libctru/source/initSystem.c @@ -19,17 +19,17 @@ extern char* fake_heap_start; extern char* fake_heap_end; static void initArgv(); +static u32 heapBase; void __attribute__((noreturn)) __ctru_exit(int rc) { - // Run the global destructors - __libc_fini_array(); + // Run the global destructors -- disabled for now (it crashes for an unknown reason) + //__libc_fini_array(); // TODO: APT exit goes here // Unmap the heap - u32 blockAddr; - svcControlMemory(&blockAddr, 0x08000000, 0x0, __heap_size, MEMOP_FREE, 0x0); + svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_FREE, 0x0); // Jump to the loader if it provided a callback if (__system_retAddr) @@ -46,11 +46,11 @@ void initSystem(void (*retAddr)(void)) __system_retAddr = __service_ptr ? retAddr : NULL; // Allocate the application heap - u32 blockAddr; - svcControlMemory(&blockAddr, 0x08000000, 0x0, __heap_size, MEMOP_ALLOC, 0x3); + heapBase = 0x08000000; + svcControlMemory(&heapBase, heapBase, 0x0, __heap_size, MEMOP_ALLOC, 0x3); // Set up newlib heap - fake_heap_start = (char*)0x08000000; + fake_heap_start = (char*)heapBase; fake_heap_end = fake_heap_start + __heap_size; // Build argc/argv if present