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

# gelf\_update\_ehdr(3)

update underlying ELF data structures

## NAME

**gelf\_update\_ehdr**, **gelf\_update\_phdr**, **gelf\_update\_shdr** – update underlying ELF data structures

## LIBRARY

library “libelf”

## SYNOPSIS

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

*int*\

**gelf\_update\_ehdr**(*Elf \*elf*, *GElf\_Ehdr \*ehdr*);

*int*\

**gelf\_update\_phdr**(*Elf \*elf*, *int ndx*, *GElf\_Phdr \*phdr*);

*int*\

**gelf\_update\_shdr**(*Elf\_Scn \*scn*, *GElf\_Shdr \*shdr*);

## DESCRIPTION

These functions are used to update ELF data structures on the underlying ELF descriptor. Class-dependent data structures in the underlying ELF descriptor are updated using the data in the class-independent GElf descriptors and the underlying ELF data structures are marked “dirty”. The conversion process signals an error if the values being copied to the target ELF data structure would exceed representation limits. GElf descriptors are described in [gelf(3)](/gelf/3.md).

Function **gelf\_update\_ehdr**() updates the ELF Executable Header with the values in the class-independent executable header *ehdr*.

Function **gelf\_update\_phdr**() updates the ELF Program Header structure at index *ndx* with the values in the class-independent program header *phdr*.

Function **gelf\_update\_shdr**() updates the ELF Section Header structure associated with section descriptor *scn* with the values in argument *shdr*.

## RETURN VALUES

These functions return a non-zero integer on success, or zero in case of an error.

## ERRORS

These functions may fail with the following errors:

- \[ELF\_E\_ARGUMENT\]

  Arguments *elf*, *ehdr*, *phdr*, *scn*, or *shdr* were NULL.

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* was not a descriptor for an ELF object.

- \[ELF\_E\_ARGUMENT\]

  Argument *elf* had an unsupported ELF class.

- \[ELF\_E\_ARGUMENT\]

  Argument *ndx* exceeded the number of entries in the program header table.

- \[ELF\_E\_ARGUMENT\]

  Section descriptor *scn* was not associated with an ELF descriptor.

- \[ELF\_E\_MODE\]

  ELF descriptor *elf* was not opened for writing or updating.

- \[ELF\_E\_RESOURCE\]

  An out of memory condition was detected.

## SEE ALSO

[elf(3)](/elf/3.md), [elf\_flagelf(3)](/elf_flagelf/3.md), [elf\_flagphdr(3)](/elf_flagphdr/3.md), [elf\_flagshdr(3)](/elf_flagshdr/3.md), [gelf(3)](/gelf/3.md), [gelf\_getehdr(3)](/gelf_getehdr/3.md), [gelf\_getphdr(3)](/gelf_getphdr/3.md), [gelf\_getshdr(3)](/gelf_getshdr/3.md)
