Changeset View
Changeset View
Standalone View
Standalone View
libexec/rtld-elf/amd64/reloc.c
Show First 20 Lines • Show All 297 Lines • ▼ Show 20 Lines | case R_X86_64_DTPOFF64: | ||||
break; | break; | ||||
case R_X86_64_DTPOFF32: | case R_X86_64_DTPOFF32: | ||||
*where32 += (Elf32_Addr)(def->st_value + | *where32 += (Elf32_Addr)(def->st_value + | ||||
rela->r_addend); | rela->r_addend); | ||||
break; | break; | ||||
case R_X86_64_RELATIVE: | case R_X86_64_RELATIVE: | ||||
*where = (Elf_Addr)(obj->relocbase + rela->r_addend); | *where = (Elf_Addr)(obj->relocbase + rela->r_addend); | ||||
break; | break; | ||||
case R_X86_64_IRELATIVE: | |||||
emaste: tiny nit, extra space here compared to others | |||||
obj->irelative_nonplt = true; | |||||
break; | |||||
/* | /* | ||||
* missing: | * missing: | ||||
* R_X86_64_GOTPCREL, R_X86_64_32, R_X86_64_32S, R_X86_64_16, | * R_X86_64_GOTPCREL, R_X86_64_32, R_X86_64_32S, R_X86_64_16, | ||||
* R_X86_64_PC16, R_X86_64_8, R_X86_64_PC8 | * R_X86_64_PC16, R_X86_64_8, R_X86_64_PC8 | ||||
*/ | */ | ||||
default: | default: | ||||
_rtld_error("%s: Unsupported relocation type %u" | _rtld_error("%s: Unsupported relocation type %u" | ||||
" in non-PLT relocations\n", obj->path, | " in non-PLT relocations\n", obj->path, | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
#ifdef dbg | #ifdef dbg | ||||
dbg("reloc_jmpslot: *%p = %p", where, (void *)target); | dbg("reloc_jmpslot: *%p = %p", where, (void *)target); | ||||
#endif | #endif | ||||
if (!ld_bind_not) | if (!ld_bind_not) | ||||
*where = target; | *where = target; | ||||
return (target); | return (target); | ||||
} | } | ||||
static void | |||||
reloc_iresolve_one(Obj_Entry *obj, const Elf_Rela *rela, | |||||
RtldLockState *lockstate) | |||||
{ | |||||
Elf_Addr *where, target, *ptr; | |||||
ptr = (Elf_Addr *)(obj->relocbase + rela->r_addend); | |||||
where = (Elf_Addr *)(obj->relocbase + rela->r_offset); | |||||
lock_release(rtld_bind_lock, lockstate); | |||||
target = call_ifunc_resolver(ptr); | |||||
wlock_acquire(rtld_bind_lock, lockstate); | |||||
*where = target; | |||||
} | |||||
int | int | ||||
reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate) | reloc_iresolve(Obj_Entry *obj, RtldLockState *lockstate) | ||||
{ | { | ||||
const Elf_Rela *relalim; | const Elf_Rela *relalim; | ||||
const Elf_Rela *rela; | const Elf_Rela *rela; | ||||
if (!obj->irelative) | if (!obj->irelative) | ||||
return (0); | return (0); | ||||
relalim = (const Elf_Rela *)((const char *)obj->pltrela + obj->pltrelasize); | obj->irelative = false; | ||||
relalim = (const Elf_Rela *)((const char *)obj->pltrela + | |||||
obj->pltrelasize); | |||||
for (rela = obj->pltrela; rela < relalim; rela++) { | for (rela = obj->pltrela; rela < relalim; rela++) { | ||||
Elf_Addr *where, target, *ptr; | if (ELF_R_TYPE(rela->r_info) == R_X86_64_IRELATIVE) | ||||
reloc_iresolve_one(obj, rela, lockstate); | |||||
} | |||||
return (0); | |||||
} | |||||
switch (ELF_R_TYPE(rela->r_info)) { | int | ||||
case R_X86_64_JMP_SLOT: | reloc_iresolve_nonplt(Obj_Entry *obj, RtldLockState *lockstate) | ||||
break; | { | ||||
const Elf_Rela *relalim; | |||||
const Elf_Rela *rela; | |||||
case R_X86_64_IRELATIVE: | if (!obj->irelative_nonplt) | ||||
ptr = (Elf_Addr *)(obj->relocbase + rela->r_addend); | return (0); | ||||
where = (Elf_Addr *)(obj->relocbase + rela->r_offset); | obj->irelative_nonplt = false; | ||||
lock_release(rtld_bind_lock, lockstate); | relalim = (const Elf_Rela *)((const char *)obj->rela + obj->relasize); | ||||
target = call_ifunc_resolver(ptr); | for (rela = obj->rela; rela < relalim; rela++) { | ||||
wlock_acquire(rtld_bind_lock, lockstate); | if (ELF_R_TYPE(rela->r_info) == R_X86_64_IRELATIVE) | ||||
*where = target; | reloc_iresolve_one(obj, rela, lockstate); | ||||
break; | |||||
} | } | ||||
} | |||||
obj->irelative = false; | |||||
return (0); | return (0); | ||||
} | } | ||||
int | int | ||||
reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate) | reloc_gnu_ifunc(Obj_Entry *obj, int flags, RtldLockState *lockstate) | ||||
{ | { | ||||
const Elf_Rela *relalim; | const Elf_Rela *relalim; | ||||
const Elf_Rela *rela; | const Elf_Rela *rela; | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |
tiny nit, extra space here compared to others