Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtld-elf: Support upcoming new ABI for R_MORELLO_JUMP_SLOT #2081

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions libexec/rtld-elf/aarch64/reloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,39 @@ reloc_plt(Obj_Entry *obj, int flags, RtldLockState *lockstate)
FUNC_PTR_REMOVE_PERMS);
#endif
for (rela = obj->pltrela; rela < relalim; rela++) {
Elf_Addr *where;
uintptr_t *where;
#ifdef __CHERI_PURE_CAPABILITY__
Elf_Addr *fragment;
#endif

where = (Elf_Addr *)(obj->relocbase + rela->r_offset);
where = (uintptr_t *)(obj->relocbase + rela->r_offset);
#ifdef __CHERI_PURE_CAPABILITY__
fragment = (Elf_Addr *)where;
#endif

switch(ELF_R_TYPE(rela->r_info)) {
#ifdef __CHERI_PURE_CAPABILITY__
case R_MORELLO_JUMP_SLOT:
/*
* XXX: This would be far more natural if the linker
* made it an R_MORELLO_RELATIVE-like fragment instead.
* https://git.morello-project.org/morello/llvm-project/-/issues/19
* Old ABI:
* - Treat as R_AARCH64_JUMP_SLOT
*
* New ABI:
* - Same representation as R_MORELLO_RELATIVE
*
* Determine which this is based on whether there's
* non-zero metadata next to the address. Remove once
* the new ABI is old enough that we can assume it is
* in use.
*/
*(uintptr_t *)where = cheri_sealentry(jump_slot_base +
*where);
if (fragment[1] == 0)
*where = cheri_sealentry(jump_slot_base +
fragment[0]);
else
*where = init_cap_from_fragment(fragment,
obj->relocbase, obj->text_rodata_cap,
(Elf_Addr)(uintptr_t)obj->relocbase,
rela->r_addend);
break;
#else
case R_AARCH64_JUMP_SLOT:
Expand All @@ -374,8 +393,8 @@ reloc_plt(Obj_Entry *obj, int flags, RtldLockState *lockstate)
#else
case R_AARCH64_TLSDESC:
#endif
reloc_tlsdesc(obj, rela, where, SYMLOOK_IN_PLT | flags,
lockstate);
reloc_tlsdesc(obj, rela, (Elf_Addr *)where,
SYMLOOK_IN_PLT | flags, lockstate);
break;
#ifdef __CHERI_PURE_CAPABILITY__
case R_MORELLO_IRELATIVE:
Expand Down
Loading