This commit is contained in:
TuxSH 2018-01-31 01:22:45 +01:00 committed by plutoo
parent 85d7ac4da1
commit e7c57fbd0b
3 changed files with 8 additions and 11 deletions

View File

@ -4,7 +4,7 @@
#include "services/sm.h" #include "services/sm.h"
#include "services/fatal.h" #include "services/fatal.h"
void NORETURN __nx_exit(LoaderReturnFn retaddr, Result rc); void NORETURN __nx_exit(Result rc, LoaderReturnFn retaddr);
static bool g_isNso = false; static bool g_isNso = false;
static Handle g_mainThreadHandle = INVALID_HANDLE; static Handle g_mainThreadHandle = INVALID_HANDLE;
@ -90,7 +90,7 @@ void envSetup(void* ctx, Handle main_thread, LoaderReturnFn saved_lr)
if (ent->Flags & EntryFlag_IsMandatory) if (ent->Flags & EntryFlag_IsMandatory)
{ {
// Encountered unknown but mandatory key, bail back to loader. // Encountered unknown but mandatory key, bail back to loader.
__nx_exit(g_loaderRetAddr, MAKERESULT(346, 100 + ent->Key)); __nx_exit(MAKERESULT(346, 100 + ent->Key), g_loaderRetAddr);
} }
break; break;

View File

@ -8,7 +8,7 @@
#include "runtime/devices/fs_dev.h" #include "runtime/devices/fs_dev.h"
void* __stack_top; void* __stack_top;
void NORETURN __nx_exit(LoaderReturnFn retaddr, Result rc); void NORETURN __nx_exit(Result rc, LoaderReturnFn retaddr);
void virtmemSetup(void); void virtmemSetup(void);
void newlibSetup(void); void newlibSetup(void);
@ -134,5 +134,5 @@ void __attribute__((weak)) NORETURN __libnx_exit(int rc)
// Clean up services. // Clean up services.
__appExit(); __appExit();
__nx_exit(envGetExitFuncPtr(), 0); __nx_exit(0, envGetExitFuncPtr());
} }

View File

@ -62,13 +62,10 @@ bss_loop:
.global __nx_exit .global __nx_exit
.type __nx_exit, %function .type __nx_exit, %function
__nx_exit: __nx_exit:
mov x8, x0
// restore stack pointer // restore stack pointer
adrp x0, __stack_top adrp x8, __stack_top
ldr x0, [x0, #:lo12:__stack_top] ldr x8, [x8, #:lo12:__stack_top]
mov sp, x0 mov sp, x8
// jump back to loader // jump back to loader
mov x0, #0 br x1
br x8