GELF\_UPDATE\_EHDR(3) Libelf Programmer's Manual GELF\_UPDATE\_EHDR(3)

# [NAME](#NAME)

gelf\_update\_ehdr - copy a class-independent ELF header into an ELF descriptor

# [SYNOPSIS](#SYNOPSIS)

```
#include <gelf.h>
int gelf_update_ehdr(Elf *elf, GElf_Ehdr *src);
```

# [DESCRIPTION](#DESCRIPTION)

**gelf\_update\_ehdr**() copies the class-independent ELF header from the structure pointed to by *src* into the ELF descriptor *elf .* The header is translated as necessary to match the class ( **ELFCLASS32** or **ELFCLASS64**) of the underlying object.

If *elf* has class **ELFCLASS32** then **e\_entry**, **e\_phoff** and **e\_shoff** must be expressible as 32-bit values. This function also marks the Ehdr dirty (see **elf\_flagehdr**()).

# [PARAMETERS](#PARAMETERS)

[*elf*](#elf)

Pointer to an ELF descriptor of kind **ELF\_K\_ELF**.

[*src*](#src)

Pointer to a **GElf\_Ehdr** structure that holds the caller’s desired header contents. Must not be NULL.

# [RETURN VALUE](#RETURN_VALUE)

On success, **gelf\_update\_ehdr**() returns a non-zero value. On failure, it returns 0 and sets elf\_errno. If *elf* is NULL, then 0 is returned without setting elf\_errno.

# [SEE ALSO](#SEE_ALSO)

[**gelf\_getehdr**(3)](/man/os/elfutils/gelf_getehdr.3), [**gelf\_newehdr**(3)](/man/os/elfutils/gelf_newehdr.3), [**elf\_flagehdr**(3)](/man/os/elfutils/elf_flagehdr.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

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

# [REPORTING BUGS](#REPORTING_BUGS)

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

2025-09-17 Libelf

---

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