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 3eb7e56 commit a913fa0
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 @@ -859,10 +859,17 @@ _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 *p,
void *rcsp, void **buf);

struct jmp_args
_rtld_unw_setcontext(struct jmp_args ret, void *p __unused, void *rcsp,
void **buf)
{
if (!C18N_ENABLED) {
__attribute__((musttail)) return (
_rtld_unw_setcontext_epilogue(ret, p, rcsp, buf));
}
return (unwind_stack(ret, rcsp, cheri_unseal(*buf, sealer_unwbuf),
get_trusted_frame()));
}
Expand All @@ -871,6 +878,10 @@ struct jmp_args
_rtld_unw_setcontext_unsealed(struct jmp_args ret, void *p __unused, void *rcsp,
void **buf)
{
if (!C18N_ENABLED) {
__attribute__((musttail)) return (
_rtld_unw_setcontext_epilogue(ret, p, rcsp, buf));
}
return (unwind_stack(ret, rcsp, *buf, get_trusted_frame()));
}

Expand Down

0 comments on commit a913fa0

Please sign in to comment.