]> Chaos Git - corbenik/ctrulib.git/commitdiff
initSystem.c: revise heap code, disable global destructors due to crashes
authorfincs <fincs.alt1@gmail.com>
Wed, 20 Aug 2014 21:32:09 +0000 (23:32 +0200)
committerfincs <fincs.alt1@gmail.com>
Wed, 20 Aug 2014 21:32:09 +0000 (23:32 +0200)
libctru/source/initSystem.c

index 6176b344a86f378227d97ca4d1b40e48c7c6b07a..0e89d638620334d1324cda17e0625f4a2a81bbee 100644 (file)
@@ -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