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

# gelf\_getehdr(3)

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

## NAME

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

## SYNOPSIS

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

## DESCRIPTION

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

## PARAMETERS

- *elf*

  Pointer to an ELF descriptor.

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

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

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

## ATTRIBUTES

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

## REPORTING BUGS

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