GELF\_GETEHDR(3) Libelf Programmer's Manual GELF\_GETEHDR(3)

# [NAME](#NAME)

gelf\_getehdr - retrieve the header of an ELF binary as a class-independent structure

# [SYNOPSIS](#SYNOPSIS)

```
#include <gelf.h>
GElf_Ehdr *gelf_getehdr(Elf *elf, GElf_Ehdr *dest );
```

# [DESCRIPTION](#DESCRIPTION)

**gelf\_getehdr()** retrieve the ELF header of the binary referenced by *elf* as a class-independent **GElf\_Ehdr** representation.

# [PARAMETERS](#PARAMETERS)

[*elf*](#elf)

Pointer to an ELF descriptor.

[*dest*](#dest)

Pointer to a caller-provided **GElf\_Ehdr** structure that will receive the translated file header. Must not be NULL. On success, the function stores the header in *\*dest*.

# [RETURN VALUE](#RETURN_VALUE)

On success, returns *dest*. On failure, returns **NULL** and sets elf\_errno. If *elf* is NULL, NULL is returned and elf\_errno is not set.

# [SEE ALSO](#SEE_ALSO)

[**gelf\_newehdr**(3)](/man/os/elfutils/gelf_newehdr.3), [**gelf\_update\_ehdr**(3)](/man/os/elfutils/gelf_update_ehdr.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

**Interface** **Attribute** **Value** gelf\_getehdr () Thread safety MT-Safe

# [REPORTING BUGS](#REPORTING_BUGS)

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

2025-09-14 Libelf

---

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