Skip to content

Commit

Permalink
c18n: Allow _rtld_unw_resume to resume purecap binaries.
Browse files Browse the repository at this point in the history
  • Loading branch information
dstolfa committed Mar 27, 2024
1 parent 5dc222b commit 93e9c0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libexec/rtld-elf/aarch64/rtld_c18n_asm.S
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ ENTRY(_rtld_dispatch_signal)
b dispatch_signal_end
END(_rtld_dispatch_signal)

ENTRY(_rtld_unw_setcontext_epilogue)
/*
* FIXME: llvm-libunwind specific ABI. This should be better specified.
*/
mov c16, c2
ldp c2, c3, [c0, #(-0x210 + 0x20)]
mov csp, c16
ret
END(_rtld_unw_setcontext_epilogue)

ENTRY(allocate_rstk)
/*
* NON-STANDARD CALLING CONVENTION
Expand Down
15 changes: 15 additions & 0 deletions libexec/rtld-elf/rtld_c18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,16 +858,31 @@ _rtld_longjmp(struct jmp_args ret, void *rcsp, void **buf)
get_trusted_frame()));
}

struct jmp_args _rtld_unw_setcontext_epilogue(struct jmp_args ret, void *rcsp,
void **buf);

struct jmp_args
_rtld_unw_setcontext(struct jmp_args ret, void *rcsp, void **buf)
{
#ifdef C18N_ENABLED
if (!C18N_ENABLED) {
__attribute__((musttail))
return (_rtld_unw_setcontext_epilogue(ret, rcsp, buf));
}
#endif
return (unwind_stack(ret, rcsp, cheri_unseal(*buf, sealer_unwbuf),
get_trusted_frame()));
}

struct jmp_args
_rtld_unw_setcontext_unsealed(struct jmp_args ret, void *rcsp, void **buf)
{
#ifdef C18N_ENABLED
if (!C18N_ENABLED) {
__attribute__((musttail))
return (_rtld_unw_setcontext_epilogue(ret, rcsp, buf));
}
#endif
return (unwind_stack(ret, rcsp, *buf, get_trusted_frame()));
}

Expand Down

0 comments on commit 93e9c0d

Please sign in to comment.