From 96af83a70e5e6e479d00ba3d7996aa8e6bdd5957 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Wed, 14 Nov 2018 21:31:45 -0500 Subject: [PATCH] Added support for exceptions. --- source/main.c | 2 +- source/trampoline.s | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/source/main.c b/source/main.c index 2cf4ecf..b74cd3c 100644 --- a/source/main.c +++ b/source/main.c @@ -9,7 +9,7 @@ const char* g_easterEgg = "Do you mean to tell me that you're thinking seriously static char g_argv[2048]; static char g_nextArgv[2048]; static char g_nextNroPath[512]; -static u64 g_nroAddr = 0; +u64 g_nroAddr = 0; static u64 g_nroSize = 0; static NroHeader g_nroHeader; static bool g_isApplication = 0; diff --git a/source/trampoline.s b/source/trampoline.s index acc25d8..aba82e1 100644 --- a/source/trampoline.s +++ b/source/trampoline.s @@ -4,6 +4,9 @@ .type nroEntrypointTrampoline, %function .align 2 +.global __libnx_exception_entry +.type __libnx_exception_entry, %function + .cfi_startproc nroEntrypointTrampoline: @@ -29,3 +32,21 @@ nroEntrypointTrampoline: b loadNro .cfi_endproc + +.section .text.__libnx_exception_entry, "ax", %progbits +.align 2 + +.cfi_startproc + +__libnx_exception_entry: + adrp x7, g_nroAddr + ldr x7, [x7, #:lo12:g_nroAddr] + cbz x7, __libnx_exception_entry_fail + br x7 + +__libnx_exception_entry_fail: + mov w0, #0xf801 + bl svcReturnFromException + b . + +.cfi_endproc