---
name: "elf_hash"
section: "3"
platform: "linux"
package: "libelf"
version: "0.197-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_hash"
---

# elf\_hash(3)

Compute the standard ELF hash or GNU hash of a string.

## 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

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

- *string*

  NULL-terminated string to be hashed.

## RETURN VALUE

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

## SEE ALSO

[**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

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

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

## REPORTING BUGS

Report bugs to \<elfutils-devel@sourceware.org\> or https://sourceware.org/bugzilla/.

## 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.
