Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/link_elf.c
Show First 20 Lines • Show All 1,464 Lines • ▼ Show 20 Lines | relocate_file(elf_file_t ef) | |||||||||
error = relocate_file1(ef, elf_lookup, elf_reloc, false); | error = relocate_file1(ef, elf_lookup, elf_reloc, false); | |||||||||
if (error == 0) | if (error == 0) | |||||||||
error = relocate_file1(ef, elf_lookup, elf_reloc, true); | error = relocate_file1(ef, elf_lookup, elf_reloc, true); | |||||||||
return (error); | return (error); | |||||||||
} | } | |||||||||
/* | /* | |||||||||
* Hash function for symbol table lookup. Don't even think about changing | * SysV hash function for symbol table lookup. It is specified by the | |||||||||
* this. It is specified by the System V ABI. | * System V ABI. | |||||||||
kib: The last sentence from the comment is worth keeping as well, IMO. | ||||||||||
*/ | */ | |||||||||
static unsigned long | static Elf32_Word | |||||||||
elf_hash(const char *name) | elf_hash(const char *name) | |||||||||
{ | { | |||||||||
const unsigned char *p = (const unsigned char *) name; | const unsigned char *p = (const unsigned char *)name; | |||||||||
Not Done Inline Actions
kib: | ||||||||||
unsigned long h = 0; | Elf32_Word h = 0; | |||||||||
Not Done Inline Actionsg is unused now? kib: g is unused now? | ||||||||||
Not Done Inline ActionsI mean, the h var type should be changed as well. kib: I mean, the h var type should be changed as well. | ||||||||||
Not Done Inline Actions
kib: | ||||||||||
unsigned long g; | ||||||||||
while (*p != '\0') { | while (*p != '\0') { | |||||||||
h = (h << 4) + *p++; | h = (h << 4) + *p++; | |||||||||
if ((g = h & 0xf0000000) != 0) | h ^= (h >> 24) & 0xf0; | |||||||||
h ^= g >> 24; | ||||||||||
h &= ~g; | ||||||||||
} | } | |||||||||
return (h); | return (h & 0x0fffffff); | |||||||||
} | } | |||||||||
static int | static int | |||||||||
link_elf_lookup_symbol1(linker_file_t lf, const char *name, c_linker_sym_t *sym, | link_elf_lookup_symbol1(linker_file_t lf, const char *name, c_linker_sym_t *sym, | |||||||||
bool see_local) | bool see_local) | |||||||||
{ | { | |||||||||
elf_file_t ef = (elf_file_t) lf; | elf_file_t ef = (elf_file_t) lf; | |||||||||
unsigned long symnum; | unsigned long symnum; | |||||||||
const Elf_Sym* symp; | const Elf_Sym* symp; | |||||||||
const char *strp; | const char *strp; | |||||||||
unsigned long hash; | Elf32_Word hash; | |||||||||
/* If we don't have a hash, bail. */ | /* If we don't have a hash, bail. */ | |||||||||
if (ef->buckets == NULL || ef->nbuckets == 0) { | if (ef->buckets == NULL || ef->nbuckets == 0) { | |||||||||
printf("link_elf_lookup_symbol: missing symbol hash table\n"); | printf("link_elf_lookup_symbol: missing symbol hash table\n"); | |||||||||
return (ENOENT); | return (ENOENT); | |||||||||
} | } | |||||||||
/* First, search hashed global symbols */ | /* First, search hashed global symbols */ | |||||||||
▲ Show 20 Lines • Show All 479 Lines • Show Last 20 Lines |
The last sentence from the comment is worth keeping as well, IMO.