Changeset View
Changeset View
Standalone View
Standalone View
libexec/rtld-elf/rtld.c
Show First 20 Lines • Show All 872 Lines • ▼ Show 20 Lines | _rtld_bind(Obj_Entry *obj, Elf_Size reloff) | ||||
const Obj_Entry *defobj; | const Obj_Entry *defobj; | ||||
Elf_Addr *where; | Elf_Addr *where; | ||||
Elf_Addr target; | Elf_Addr target; | ||||
RtldLockState lockstate; | RtldLockState lockstate; | ||||
rlock_acquire(rtld_bind_lock, &lockstate); | rlock_acquire(rtld_bind_lock, &lockstate); | ||||
if (sigsetjmp(lockstate.env, 0) != 0) | if (sigsetjmp(lockstate.env, 0) != 0) | ||||
lock_upgrade(rtld_bind_lock, &lockstate); | lock_upgrade(rtld_bind_lock, &lockstate); | ||||
if (obj->pltrel) | if (obj->pltrel) | ||||
kib: obj->path != NULL according to style | |||||
rel = (const Elf_Rel *)((const char *)obj->pltrel + reloff); | rel = (const Elf_Rel *)((const char *)obj->pltrel + reloff); | ||||
else | else | ||||
rel = (const Elf_Rel *)((const char *)obj->pltrela + reloff); | rel = (const Elf_Rel *)((const char *)obj->pltrela + reloff); | ||||
where = (Elf_Addr *)(obj->relocbase + rel->r_offset); | where = (Elf_Addr *)(obj->relocbase + rel->r_offset); | ||||
def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, SYMLOOK_IN_PLT, | def = find_symdef(ELF_R_SYM(rel->r_info), obj, &defobj, SYMLOOK_IN_PLT, | ||||
NULL, &lockstate); | NULL, &lockstate); | ||||
if (def == NULL) | if (def == NULL) | ||||
rtld_die(); | rtld_die(); | ||||
if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) | if (ELF_ST_TYPE(def->st_info) == STT_GNU_IFUNC) | ||||
target = (Elf_Addr)rtld_resolve_ifunc(defobj, def); | target = (Elf_Addr)rtld_resolve_ifunc(defobj, def); | ||||
else | else | ||||
target = (Elf_Addr)(defobj->relocbase + def->st_value); | target = (Elf_Addr)(defobj->relocbase + def->st_value); | ||||
dbg("\"%s\" in \"%s\" ==> %p in \"%s\"", | dbg("\"%s\" in \"%s\" ==> %p in \"%s\"", | ||||
defobj->strtab + def->st_name, basename(obj->path), | defobj->strtab + def->st_name, | ||||
(void *)target, basename(defobj->path)); | obj->path == NULL ? NULL : basename(obj->path), | ||||
(void *)target, | |||||
defobj->path == NULL ? NULL : basename(defobj->path)); | |||||
/* | /* | ||||
* Write the new contents for the jmpslot. Note that depending on | * Write the new contents for the jmpslot. Note that depending on | ||||
* architecture, the value which we need to return back to the | * architecture, the value which we need to return back to the | ||||
* lazy binding trampoline may or may not be the target | * lazy binding trampoline may or may not be the target | ||||
* address. The value returned from reloc_jmpslot() is the value | * address. The value returned from reloc_jmpslot() is the value | ||||
* that the trampoline needs. | * that the trampoline needs. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 4,988 Lines • Show Last 20 Lines |
obj->path != NULL according to style