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

# [NAME](#NAME)

gelf\_update\_phdr - copy a class-independent program header table entry into an ELF descriptor

# [SYNOPSIS](#SYNOPSIS)

```
#include <gelf.h>
int gelf_update_phdr (Elf *elf, int ndx, GElf_Phdr *src);
```

# [DESCRIPTION](#DESCRIPTION)

**gelf\_update\_phdr**() copies the class-independent program header table entry from the structure pointed to by *src* into the program header table of *elf* at index *ndx .* The program header table entry is translated as necessary to match the class (**ELFCLASS32** or **ELFCLASS64**) of the underlying object file.

If *elf* has class **ELFCLASS32** then **p\_offset**, **p\_vaddr**, **p\_paddr**, **p\_filesz**, **p\_memsz**, and **p\_align** must fit within unsigned 32-bit values.

# [PARAMETERS](#PARAMETERS)

[*elf*](#elf)

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

[*ndx*](#ndx)

Index of the program header table entry to be updated. The number of program header table entries associated with *elf* can be obtained with **elf\_getphdrnum**().

[*src*](#src)

Pointer to a **GElf\_Phdr** structure that holds the caller's desired program header table entry contents. *src* must not be NULL.

# [RETURN VALUE](#RETURN_VALUE)

On success, this function returns a non-zero value and updates the program header table entry at index *ndx*. The program header table will be flagged with **ELF\_F\_DIRTY**. 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)

[**elf\_flagphdr**(3)](/man/os/elfutils/elf_flagphdr.3), [**elf\_getphdrnum**(3)](/man/os/elfutils/elf_getphdrnum.3), [**gelf\_getphdr**(3)](/man/os/elfutils/gelf_getphdr.3), [**gelf\_newphdr**(3)](/man/os/elfutils/gelf_newphdr.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

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

# [REPORTING BUGS](#REPORTING_BUGS)

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

2025-12-27 Libelf

---

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