mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 13:02:38 +02:00
Use custom funcs for handling init_array/fini_array. Updated crt0.
This commit is contained in:
parent
19f0b5a828
commit
a1815dd7b9
@ -1,5 +1,5 @@
|
|||||||
.section ".crt0","ax"
|
.section ".crt0","ax"
|
||||||
.global _start, _sysexit, main
|
.global _start
|
||||||
|
|
||||||
_start:
|
_start:
|
||||||
bl startup
|
bl startup
|
||||||
@ -40,6 +40,7 @@ got_loop:
|
|||||||
subs x1, x1, #8
|
subs x1, x1, #8
|
||||||
bne got_loop
|
bne got_loop
|
||||||
|
|
||||||
|
mov x0, x28
|
||||||
ldr x3, =initSystem
|
ldr x3, =initSystem
|
||||||
add x3, x3, x28
|
add x3, x3, x28
|
||||||
blr x3
|
blr x3
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
|
.text
|
||||||
.global initSystem
|
.global initSystem
|
||||||
.type initSystem, %function
|
.type initSystem, %function
|
||||||
|
|
||||||
initSystem:
|
initSystem:
|
||||||
stp x29, x30, [sp, #-16]!
|
stp x29, x30, [sp, #-16]!
|
||||||
|
adr x1, __nx_binarybase
|
||||||
|
str x0, [x1]
|
||||||
bl __libnx_init
|
bl __libnx_init
|
||||||
|
|
||||||
bl __appInit
|
bl __appInit
|
||||||
//bl __libc_init_array //Currently broken since this doesn't use .got.
|
bl __nx_libc_init_array
|
||||||
ldp x29, x30, [sp], #16
|
ldp x29, x30, [sp], #16
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -14,8 +17,83 @@ initSystem:
|
|||||||
.type __nx_exit, %function
|
.type __nx_exit, %function
|
||||||
|
|
||||||
__nx_exit:
|
__nx_exit:
|
||||||
//bl __libc_fini_array//See above.
|
bl __nx_libc_fini_array
|
||||||
bl __appExit
|
bl __appExit
|
||||||
|
|
||||||
b __libnx_exit
|
b __libnx_exit
|
||||||
|
|
||||||
|
__nx_libc_init_array:
|
||||||
|
stp x29, x30, [sp, #-16]!
|
||||||
|
stp x21, x22, [sp, #-16]!
|
||||||
|
stp x19, x20, [sp, #-16]!
|
||||||
|
adr x3, __nx_binarybase
|
||||||
|
ldr x20, [x3]
|
||||||
|
|
||||||
|
ldr x0, =__preinit_array_start
|
||||||
|
ldr x1, =__preinit_array_end
|
||||||
|
sub x1, x1, x0
|
||||||
|
add x21, x0, x20
|
||||||
|
lsr x19, x1, #3
|
||||||
|
cbz x19, __nx_libc_init_array_end0
|
||||||
|
|
||||||
|
__nx_libc_init_array_lp0:
|
||||||
|
ldr x3, [x21], #8
|
||||||
|
sub x19, x19, #1
|
||||||
|
add x3, x3, x20
|
||||||
|
blr x3
|
||||||
|
cbnz x19, __nx_libc_init_array_lp0
|
||||||
|
|
||||||
|
__nx_libc_init_array_end0:
|
||||||
|
bl _init
|
||||||
|
|
||||||
|
ldr x0, =__init_array_start
|
||||||
|
ldr x1, =__init_array_end
|
||||||
|
sub x1, x1, x0
|
||||||
|
add x21, x0, x20
|
||||||
|
lsr x19, x1, #3
|
||||||
|
cbz x19, __nx_libc_init_array_end1
|
||||||
|
|
||||||
|
__nx_libc_init_array_lp1:
|
||||||
|
ldr x3, [x21], #8
|
||||||
|
sub x19, x19, #1
|
||||||
|
add x3, x3, x20
|
||||||
|
blr x3
|
||||||
|
cbnz x19, __nx_libc_init_array_lp1
|
||||||
|
|
||||||
|
__nx_libc_init_array_end1:
|
||||||
|
ldp x19, x20, [sp], #16
|
||||||
|
ldp x21, x22, [sp], #16
|
||||||
|
ldp x29, x30, [sp], #16
|
||||||
|
ret
|
||||||
|
|
||||||
|
__nx_libc_fini_array:
|
||||||
|
stp x29, x30, [sp, #-16]!
|
||||||
|
stp x21, x22, [sp, #-16]!
|
||||||
|
stp x19, x20, [sp, #-16]!
|
||||||
|
adr x3, __nx_binarybase
|
||||||
|
ldr x20, [x3]
|
||||||
|
|
||||||
|
ldr x0, =__fini_array_start
|
||||||
|
ldr x1, =__fini_array_end
|
||||||
|
sub x1, x1, x0
|
||||||
|
add x21, x0, x20
|
||||||
|
lsr x19, x1, #3
|
||||||
|
cbz x19, __nx_libc_fini_array_end
|
||||||
|
|
||||||
|
__nx_libc_fini_array_lp:
|
||||||
|
sub x19, x19, #1
|
||||||
|
ldr x3, [x21, x19, lsl #3]
|
||||||
|
add x3, x3, x20
|
||||||
|
blr x3
|
||||||
|
cbnz x19, __nx_libc_fini_array_lp
|
||||||
|
|
||||||
|
__nx_libc_fini_array_end:
|
||||||
|
ldp x19, x20, [sp], #16
|
||||||
|
ldp x21, x22, [sp], #16
|
||||||
|
ldp x29, x30, [sp], #16
|
||||||
|
ret
|
||||||
|
|
||||||
|
.data
|
||||||
|
__nx_binarybase:
|
||||||
|
.dword 0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user