ELF\_HASH(3) Libelf Programmer's Manual ELF\_HASH(3)

# [NAME](#NAME)

elf\_hash, elf\_gnu\_hash - Compute the standard ELF hash or GNU hash of a string.

# [SYNOPSIS](#SYNOPSIS)

```
#include <libelf.h>
unsigned long int elf_hash(const char *string);
unsigned long int elf_gnu_hash(const char *string);
```

# [DESCRIPTION](#DESCRIPTION)

The **elf\_hash** function computes the standard ELF hash value for a null-terminated string. The hash values are typically used in ELF object files for symbol table hashing. The hash function is used in SHT\_HASH sections as it avoids generating architecture-dependent values and is suitable for use across architectures.

The **elf\_gnu\_hash** function computes the GNU-style hash value of a null-terminated string, used in the **SHT\_GNU\_HASH** section.

# [PARAMETERS](#PARAMETERS)

[*string*](#string)

NULL-terminated string to be hashed.

# [RETURN VALUE](#RETURN_VALUE)

These functions return a hash value for *string*. Only the lower 32 bits of the return value are used.

# [SEE ALSO](#SEE_ALSO)

[**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

For an explanation of the terms used in this section, see [**attributes**(7)](/man/os/elfutils/attributes.7).

**Interface** **Attribute** **Value** elf\_hash (), elf\_gnu\_hash () Thread safety MT-Safe

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;elfutils-devel@sourceware.org&gt; or https://sourceware.org/bugzilla/.

# [HISTORY](#HISTORY)

**elf\_gnu\_hash** first appeared in elfutils 0.122. This function is a elfutils libelf extension and may not be available in other libelf implementations.

2025-03-31 Libelf

---

Document: elf_gnu_hash(3) from elfutils 0.196-r0 (Chainguard OS)
Source: https://sourceware.org/git/elfutils.git
