---
name: "gelf_update_ehdr"
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_update_ehdr"
---

# gelf\_update\_ehdr(3)

copy a class-independent ELF header into an ELF descriptor

## NAME

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

## SYNOPSIS

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

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

- *elf*

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

- *src*

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

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

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

## ATTRIBUTES

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

## REPORTING BUGS

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