]> Chaos Git - corbenik/ctrulib.git/commitdiff
initSystem: fix global ctor/dtor code
authorfincs <fincs.alt1@gmail.com>
Wed, 27 Aug 2014 22:00:53 +0000 (00:00 +0200)
committerfincs <fincs.alt1@gmail.com>
Wed, 27 Aug 2014 22:00:53 +0000 (00:00 +0200)
libctru/source/initSystem.c

index 0179a7d5371aa72c82c3463f01d070b9f58bfc00..57ef26da6aadee4cbdcf308c9ba2ab087b7c09c6 100644 (file)
@@ -14,7 +14,8 @@ extern u32 __heap_size, __linear_heap_size;
 extern const char* __system_arglist;
 
 // newlib definitions we need
-void __libc_fini_array();
+void __libc_init_array(void);
+void __libc_fini_array(void);
 extern char* fake_heap_start;
 extern char* fake_heap_end;
 
@@ -23,8 +24,8 @@ static u32 heapBase;
 
 void __attribute__((noreturn)) __ctru_exit(int rc)
 {
-       // Run the global destructors -- disabled for now (it crashes for an unknown reason)
-       //__libc_fini_array();
+       // Run the global destructors
+       __libc_fini_array();
 
        // TODO: APT exit goes here
 
@@ -63,6 +64,9 @@ void initSystem(void (*retAddr)(void))
        initArgv();
 
        // TODO: APT init goes here
+
+       // Run the global constructors
+       __libc_init_array();
 }
 
 void initArgv()