mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 13:02:38 +02:00
Fixed register corruption in crt0 introduced by the exception commit. Only handle exceptions when __libnx_exception_handler is defined by the user, and updated comments.
This commit is contained in:
parent
4e4d5ef320
commit
12ee6e502e
@ -13,11 +13,19 @@
|
|||||||
|
|
||||||
// Called by crt0 when the args at the time of entry indicate an exception occured.
|
// Called by crt0 when the args at the time of entry indicate an exception occured.
|
||||||
|
|
||||||
|
.weak __libnx_exception_handler
|
||||||
|
|
||||||
.weak __libnx_exception_entry
|
.weak __libnx_exception_entry
|
||||||
CODE_BEGIN __libnx_exception_entry
|
CODE_BEGIN __libnx_exception_entry
|
||||||
cmp x1, #0
|
cmp x1, #0
|
||||||
beq __libnx_exception_entry_abort
|
beq __libnx_exception_entry_abort
|
||||||
|
|
||||||
|
// Abort exception handling when __libnx_exception_handler is not defined.
|
||||||
|
adrp x5, :got:__libnx_exception_handler
|
||||||
|
ldr x5, [x5, #:got_lo12:__libnx_exception_handler]
|
||||||
|
cmp x5, #0
|
||||||
|
beq __libnx_exception_entry_abort
|
||||||
|
|
||||||
// Load IsCurrentProcessBeingDebugged.
|
// Load IsCurrentProcessBeingDebugged.
|
||||||
|
|
||||||
stp x9, x10, [sp, #-16]!
|
stp x9, x10, [sp, #-16]!
|
||||||
|
@ -21,12 +21,15 @@ extern u32 __nx_applet_type;
|
|||||||
// Must be a multiple of 0x200000.
|
// Must be a multiple of 0x200000.
|
||||||
__attribute__((weak)) size_t __nx_heap_size = 0;
|
__attribute__((weak)) size_t __nx_heap_size = 0;
|
||||||
|
|
||||||
/// Override these with your own if you're using __libnx_exception_handler. __nx_exception_stack is the stack-bottom.
|
/// Override these with your own if you're using \ref__libnx_exception_handler. __nx_exception_stack is the stack-bottom. Update \ref __nx_exception_stack_size if you change this.
|
||||||
__attribute__((weak)) alignas(16) u8 __nx_exception_stack[0x400];
|
__attribute__((weak)) alignas(16) u8 __nx_exception_stack[0x400];
|
||||||
__attribute__((weak)) u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
|
__attribute__((weak)) u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
|
||||||
/// By default exception handling will be aborted when the current process is being debugged. Set this to non-zero to disable that.
|
/// By default exception handling will be aborted when the current process is being debugged. Set this to non-zero to disable that.
|
||||||
__attribute__((weak)) u32 __nx_exception_ignoredebug = 0;
|
__attribute__((weak)) u32 __nx_exception_ignoredebug = 0;
|
||||||
|
|
||||||
|
/// Override this with your own func to handle exceptions. See \ref __nx_exception_stack. See here: https://switchbrew.org/wiki/SVC#Exception_handling
|
||||||
|
void __attribute__((weak)) __libnx_exception_handler(ThreadExceptionDump *ctx);
|
||||||
|
|
||||||
ThreadExceptionDump __nx_exceptiondump;
|
ThreadExceptionDump __nx_exceptiondump;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -175,7 +178,3 @@ void __attribute__((weak)) NORETURN __libnx_exit(int rc)
|
|||||||
__nx_exit(0, envGetExitFuncPtr());
|
__nx_exit(0, envGetExitFuncPtr());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// You can override this with your own func to handle exceptions. See here: https://switchbrew.org/wiki/SVC#Exception_handling
|
|
||||||
void __attribute__((weak)) __libnx_exception_handler(ThreadExceptionDump *ctx)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -27,6 +27,10 @@ startup:
|
|||||||
b __libnx_exception_entry
|
b __libnx_exception_entry
|
||||||
|
|
||||||
bssclr_start:
|
bssclr_start:
|
||||||
|
mov x27, x7
|
||||||
|
mov x25, x5
|
||||||
|
mov x26, x4
|
||||||
|
|
||||||
// clear .bss
|
// clear .bss
|
||||||
adrp x0, __bss_start__
|
adrp x0, __bss_start__
|
||||||
adrp x1, __bss_end__
|
adrp x1, __bss_end__
|
||||||
@ -53,9 +57,9 @@ bss_loop:
|
|||||||
bl __nx_dynamic
|
bl __nx_dynamic
|
||||||
|
|
||||||
// initialize system
|
// initialize system
|
||||||
mov x0, x5
|
mov x0, x25
|
||||||
mov x1, x4
|
mov x1, x26
|
||||||
mov x2, x7
|
mov x2, x27
|
||||||
bl __libnx_init
|
bl __libnx_init
|
||||||
|
|
||||||
// call entrypoint
|
// call entrypoint
|
||||||
|
Loading…
Reference in New Issue
Block a user