ELF_HASH(3)

πŸ’– ELF_HASH(3) πŸ’–

okay bestie, welcome to libelf's cute lil hash corner, from the Libelf Programmer's Manual ✨ this page covers elf_hash and elf_gnu_hash β€” yes they're basically twins, and yes you're gonna love them πŸ’…


🌸 NAME 🌸

elf_hash, elf_gnu_hash β€” compute the standard ELF hash or GNU hash of a string 🧚


✨ SYNOPSIS ✨

#include <libelf.h>

unsigned long int elf_hash(const char *string);
unsigned long int elf_gnu_hash(const char *string);

πŸ¦‹ DESCRIPTION πŸ¦‹

so elf_hash computes the standard ELF hash value for a null-terminated string, periodt. these hash values are typically used in ELF object files for symbol table hashing β€” very demure, very mindful πŸŽ€

the way this one is used in SHT_HASH sections… it's because it avoids generating architecture-dependent values and is suitable for use across architectures. it's giving portable queen πŸ‘‘

meanwhile elf_gnu_hash computes the GNU-style hash value of a null-terminated string, and it's the one used in the SHT_GNU_HASH section. different section, same slay 🌈


πŸŽ€ PARAMETERS πŸŽ€

  • string β€” a NULL-terminated string to be hashed. give it a string, bestie, and it gets hashed πŸ’œ

⭐ RETURN VALUE ⭐

these functions return a hash value for string. but lowkey important: only the lower 32 bits of the return value are used πŸ‘€ so don't go getting attached to the whole unsigned long int, ok?


πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’… ATTRIBUTES πŸ’…

for an explanation of the terms used in this section, see attributes(7).

  • elf_hash(), elf_gnu_hash() β€” Thread safety: MT-Safe πŸ”₯ (yes bestie, they're thread-safe, we love to see it)

😭 REPORTING BUGS 😭

found a bug? not the vibe fr fr. report it to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/ 🫢


πŸ•°οΈ HISTORY πŸ•°οΈ

elf_gnu_hash first appeared in elfutils 0.122 🌟

⚠️ heads up bestie: this function is an elfutils libelf extension and may not be available in other libelf implementations. so like… vibe check your libelf before you commit, iykyk πŸ’€

and that's the whole page, no cap. this cutie dropped as part of Libelf, dated 2025-03-31, filed under ELF_HASH(3) β€” go forth and hash responsibly, bestie πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά

πŸ“¦ where this page comes from