Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit b74f34b

Browse files
committed
Change the parameters of start
On the switch, `start` takes two parameters : an exception pointer, and a handle to the main thread. For libtransistor, we'll also add a third one: a context handle. This should allow ace_loader to start apps expecting the usual switch treatment, while still providing the context to libtransistor binaries.
1 parent 2415906 commit b74f34b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

lib/crt0.nro.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _mod_header:
4141
start:
4242
sub sp, sp, 0x10
4343
stp x29, x30, [sp]
44-
adrp x1, _start // aslr base
44+
adrp x3, _start // aslr base
4545
bl _libtransistor_start
4646
ldp x29, x30, [sp], 0x10
4747
ret

lib/crt0.nso.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ _mod_header:
3737

3838
.section .text, "e"
3939
start:
40-
adrp x1, _start // aslr base
40+
adrp x3, _start // aslr base
4141
bl _libtransistor_start
4242
loop:
4343
.global _exit

lib/crt0_common.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,19 @@ static int socklog_read(struct _reent *reent, void *v, char *ptr, int len) {
119119
#define DEFAULT_NOCONTEXT_HEAP_SIZE 0x400000
120120

121121
static bool dont_finalize_bsd = false;
122+
static thread_h MAIN_HANDLE;
122123

123-
int _libtransistor_start(libtransistor_context_t *ctx, void *aslr_base) {
124+
int _libtransistor_start(void *exception_info_ptr, thread_h main_handle, libtransistor_context_t *ctx, void *aslr_base) {
124125
if(relocate(aslr_base)) {
125126
return -4;
126127
}
127128

128129
__guard_setup();
129-
130+
131+
MAIN_HANDLE = main_handle;
132+
133+
dbg_printf("exception_ptr: %x", exception_info_ptr);
134+
dbg_printf("main handle: %x", main_handle);
130135
dbg_printf("aslr base: %p", aslr_base);
131136
dbg_printf("ctx: %p", ctx);
132137

0 commit comments

Comments
 (0)