__libc_init_array needs run after stack adjustment, __libc_fini_array before original stack is restored
This commit is contained in:
parent
ed72f9474b
commit
168d967743
@ -15,9 +15,6 @@ void __attribute__((weak)) __attribute__((noreturn)) __libctru_exit(int rc)
|
||||
{
|
||||
u32 tmp=0;
|
||||
|
||||
// Run the global destructors
|
||||
__libc_fini_array();
|
||||
|
||||
__appExit();
|
||||
|
||||
// Unmap the linear heap
|
||||
|
@ -12,9 +12,6 @@ void __system_allocateHeaps();
|
||||
void __system_initArgv();
|
||||
void __appInit();
|
||||
|
||||
// newlib definitions we need
|
||||
void __libc_init_array(void);
|
||||
|
||||
|
||||
void __ctru_exit(int rc);
|
||||
|
||||
@ -32,6 +29,4 @@ void __attribute__((weak)) __libctru_init(void (*retAddr)(void))
|
||||
|
||||
__appInit();
|
||||
|
||||
// Run the global constructors
|
||||
__libc_init_array();
|
||||
}
|
||||
|
@ -16,12 +16,14 @@ initSystem:
|
||||
ldr sp, [r2]
|
||||
|
||||
ldr r3, =__stacksize__
|
||||
ldr r3, [r3]
|
||||
ldr r3, [r3]
|
||||
add sp, sp, r3
|
||||
add sp, sp, #7
|
||||
bics sp, sp, #7
|
||||
str sp, [r2]
|
||||
|
||||
bl __libc_init_array
|
||||
|
||||
ldr r2, =saved_stack
|
||||
ldr lr, [r2,#4]
|
||||
bx lr
|
||||
@ -31,6 +33,8 @@ initSystem:
|
||||
.type __ctru_exit, %function
|
||||
|
||||
__ctru_exit:
|
||||
bl __libc_fini_array
|
||||
|
||||
ldr r2, =saved_stack
|
||||
ldr sp, [r2]
|
||||
b __libctru_exit
|
||||
|
Loading…
Reference in New Issue
Block a user