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 26, 2024
1 parent 8d29f2c commit 72051da
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 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,13 @@ ENTRY(_rtld_dispatch_signal)
b dispatch_signal_end
END(_rtld_dispatch_signal)

ENTRY(_rtld_unw_setcontext_epilogue)
mov c16, c3
ldp c3, c4, [c4, #-0x030]
mov csp, c16
ret
END(_rtld_unw_setcontext_epilogue)

ENTRY(allocate_rstk)
/*
* NON-STANDARD CALLING CONVENTION
Expand Down
11 changes: 11 additions & 0 deletions libexec/rtld-elf/rtld_c18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,16 +858,27 @@ _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)
{
if (!C18N_ENABLED) {
__attribute__((musttail)) return (
_rtld_unw_setcontext_epilogue(ret, rcsp, buf));
}
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)
{
if (!C18N_ENABLED) {
__attribute__((musttail)) return (
_rtld_unw_setcontext_epilogue(ret, rcsp, buf));
}
return (unwind_stack(ret, rcsp, *buf, get_trusted_frame()));
}

Expand Down

0 comments on commit 72051da

Please sign in to comment.