---
name: "elf_hash"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/elf_hash"
---

# elf\_hash(3)

compute a hash value for a string

## NAME

**elf\_hash** – compute a hash value for a string

## LIBRARY

library “libelf”

## SYNOPSIS

**#include \<libelf.h\>**

*unsigned long*\

**elf\_hash**(*const char \*name*);

## DESCRIPTION

Function **elf\_hash**() computes a portable hash value for the null terminated string pointed to by argument *name*.

The hash value returned is will be identical across machines of different architectures. This allows hash tables to be built on one machine and correctly used on another of a different architecture. The hash value returned is also guaranteed *not* to be the bit pattern of all ones (~0UL).

## IMPLEMENTATION NOTES

The library internally uses unsigned 32 bit arithmetic to compute the hash value.

## SEE ALSO

[elf(3)](/elf/3.md), [gelf(3)](/gelf/3.md)
