Changeset View
Changeset View
Standalone View
Standalone View
libexec/rtld-elf/rtld.c
Show First 20 Lines • Show All 870 Lines • ▼ Show 20 Lines | digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath, | ||||
const Elf_Dyn *dynp; | const Elf_Dyn *dynp; | ||||
Needed_Entry **needed_tail = &obj->needed; | Needed_Entry **needed_tail = &obj->needed; | ||||
Needed_Entry **needed_filtees_tail = &obj->needed_filtees; | Needed_Entry **needed_filtees_tail = &obj->needed_filtees; | ||||
Needed_Entry **needed_aux_filtees_tail = &obj->needed_aux_filtees; | Needed_Entry **needed_aux_filtees_tail = &obj->needed_aux_filtees; | ||||
const Elf_Hashelt *hashtab; | const Elf_Hashelt *hashtab; | ||||
const Elf32_Word *hashval; | const Elf32_Word *hashval; | ||||
Elf32_Word bkt, nmaskwords; | Elf32_Word bkt, nmaskwords; | ||||
int bloom_size32; | int bloom_size32; | ||||
bool nmw_power2; | |||||
int plttype = DT_REL; | int plttype = DT_REL; | ||||
*dyn_rpath = NULL; | *dyn_rpath = NULL; | ||||
*dyn_soname = NULL; | *dyn_soname = NULL; | ||||
*dyn_runpath = NULL; | *dyn_runpath = NULL; | ||||
obj->bind_now = false; | obj->bind_now = false; | ||||
for (dynp = obj->dynamic; dynp->d_tag != DT_NULL; dynp++) { | for (dynp = obj->dynamic; dynp->d_tag != DT_NULL; dynp++) { | ||||
▲ Show 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | digest_dynamic1(Obj_Entry *obj, int early, const Elf_Dyn **dyn_rpath, | ||||
case DT_GNU_HASH: | case DT_GNU_HASH: | ||||
{ | { | ||||
hashtab = (const Elf_Hashelt *)(obj->relocbase + | hashtab = (const Elf_Hashelt *)(obj->relocbase + | ||||
dynp->d_un.d_ptr); | dynp->d_un.d_ptr); | ||||
obj->nbuckets_gnu = hashtab[0]; | obj->nbuckets_gnu = hashtab[0]; | ||||
obj->symndx_gnu = hashtab[1]; | obj->symndx_gnu = hashtab[1]; | ||||
nmaskwords = hashtab[2]; | nmaskwords = hashtab[2]; | ||||
bloom_size32 = (__ELF_WORD_SIZE / 32) * nmaskwords; | bloom_size32 = (__ELF_WORD_SIZE / 32) * nmaskwords; | ||||
/* Number of bitmask words is required to be power of 2 */ | |||||
nmw_power2 = ((nmaskwords & (nmaskwords - 1)) == 0); | |||||
obj->maskwords_bm_gnu = nmaskwords - 1; | obj->maskwords_bm_gnu = nmaskwords - 1; | ||||
kib: Remove the nmw_power2 variable altogether. It was introduced only to simplify the expression… | |||||
obj->shift2_gnu = hashtab[3]; | obj->shift2_gnu = hashtab[3]; | ||||
obj->bloom_gnu = (Elf_Addr *) (hashtab + 4); | obj->bloom_gnu = (Elf_Addr *) (hashtab + 4); | ||||
obj->buckets_gnu = hashtab + 4 + bloom_size32; | obj->buckets_gnu = hashtab + 4 + bloom_size32; | ||||
obj->chain_zero_gnu = obj->buckets_gnu + obj->nbuckets_gnu - | obj->chain_zero_gnu = obj->buckets_gnu + obj->nbuckets_gnu - | ||||
obj->symndx_gnu; | obj->symndx_gnu; | ||||
obj->valid_hash_gnu = nmw_power2 && obj->nbuckets_gnu > 0 && | /* Number of bitmask words is required to be power of 2 */ | ||||
obj->buckets_gnu != NULL; | obj->valid_hash_gnu = powerof2(nmaskwords) && | ||||
obj->nbuckets_gnu > 0 && obj->buckets_gnu != NULL; | |||||
Not Done Inline ActionsI looked again at the glibc _dl_setup_hash() function from their dl-lookup.c, and there is no check for bitmask being non-zero. In fact, zero bitmask means that there is 32 bitmask words. I am not sure that this part is correct, at all. kib: I looked again at the glibc _dl_setup_hash() function from their dl-lookup.c, and there is no… | |||||
} | } | ||||
break; | break; | ||||
case DT_NEEDED: | case DT_NEEDED: | ||||
if (!obj->rtld) { | if (!obj->rtld) { | ||||
Needed_Entry *nep = NEW(Needed_Entry); | Needed_Entry *nep = NEW(Needed_Entry); | ||||
nep->name = dynp->d_un.d_val; | nep->name = dynp->d_un.d_val; | ||||
nep->obj = NULL; | nep->obj = NULL; | ||||
▲ Show 20 Lines • Show All 4,050 Lines • Show Last 20 Lines |
Remove the nmw_power2 variable altogether. It was introduced only to simplify the expression for valid_gnu_hash.
The comment about 'power of 2' should be moved to valid_gnu_hash and updated.