kernel & runtime_loader: Adopt the optimized version of the elf_hash routine.
Taken from FreeBSD but musl has the same. Does improve loading time. Change-Id: I41c1f37e8948169a50d8989cc465998282fadaf8 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7898 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
ffc1a5219d
commit
6c418101c4
+14
-16
@@ -301,22 +301,6 @@ delete_elf_image(struct elf_image_info *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static uint32
|
|
||||||
elf_hash(const char *name)
|
|
||||||
{
|
|
||||||
uint32 hash = 0;
|
|
||||||
uint32 temp;
|
|
||||||
|
|
||||||
while (*name) {
|
|
||||||
hash = (hash << 4) + (uint8)*name++;
|
|
||||||
if ((temp = hash & 0xf0000000) != 0)
|
|
||||||
hash ^= temp >> 24;
|
|
||||||
hash &= ~temp;
|
|
||||||
}
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
get_symbol_type_string(elf_sym *symbol)
|
get_symbol_type_string(elf_sym *symbol)
|
||||||
{
|
{
|
||||||
@@ -602,6 +586,20 @@ void dump_symbol(struct elf_image_info *image, elf_sym *sym)
|
|||||||
#endif // ELF32_COMPAT
|
#endif // ELF32_COMPAT
|
||||||
|
|
||||||
|
|
||||||
|
static uint32
|
||||||
|
elf_hash(const char* _name)
|
||||||
|
{
|
||||||
|
const uint8* name = (const uint8*)_name;
|
||||||
|
|
||||||
|
uint32 h = 0;
|
||||||
|
while (*name != '\0') {
|
||||||
|
h = (h << 4) + *name++;
|
||||||
|
h ^= (h >> 24) & 0xf0;
|
||||||
|
}
|
||||||
|
return (h & 0x0fffffff);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static elf_sym *
|
static elf_sym *
|
||||||
elf_find_symbol(struct elf_image_info *image, const char *name,
|
elf_find_symbol(struct elf_image_info *image, const char *name,
|
||||||
const elf_version_info *lookupVersion, bool lookupDefault)
|
const elf_version_info *lookupVersion, bool lookupDefault)
|
||||||
|
|||||||
@@ -49,16 +49,12 @@ elf_hash(const char* _name)
|
|||||||
{
|
{
|
||||||
const uint8* name = (const uint8*)_name;
|
const uint8* name = (const uint8*)_name;
|
||||||
|
|
||||||
uint32 hash = 0;
|
uint32 h = 0;
|
||||||
uint32 temp;
|
while (*name != '\0') {
|
||||||
|
h = (h << 4) + *name++;
|
||||||
while (*name) {
|
h ^= (h >> 24) & 0xf0;
|
||||||
hash = (hash << 4) + *name++;
|
|
||||||
if ((temp = hash & 0xf0000000))
|
|
||||||
hash ^= temp >> 24;
|
|
||||||
hash &= ~temp;
|
|
||||||
}
|
}
|
||||||
return hash;
|
return (h & 0x0fffffff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user