GELF\_GETPHDR(3) Libelf Programmer's Manual GELF\_GETPHDR(3)

# [NAME](#NAME)

gelf\_getphdr - Retrieve class-independent program header table entries for an ELF object file

# [SYNOPSIS](#SYNOPSIS)

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

# [DESCRIPTION](#DESCRIPTION)

Retrieve the class-independent program header table entry at index *ndx* for ELF descriptor *elf* and store it in *dst*. See [**elf\_getphdrnum**(3)](/man/os/elfutils/elf_getphdrnum.3) for information on how to acquire the number of entries in the program header table.

# [PARAMETERS](#PARAMETERS)

[*elf*](#elf)

ELF descriptor of kind **ELF\_K\_ELF** from which to retrieve the program header table entry.

[*ndx*](#ndx)

The index of the program header table entry to be retrieved.

[*dst*](#dst)

Pointer to a caller-provided **GElf\_Phdr** that will receive the requested program header table entry.

# [RETURN VALUE](#RETURN_VALUE)

On success, the requested entry is copied into *dst* and *dst is returned.* On failure, NULL is returned and elf\_errno is set. If *elf* is NULL, then NULL is returned and elf\_errno is not set.

# [SEE ALSO](#SEE_ALSO)

[**elf32\_getphdr**(3)](/man/os/elfutils/elf32_getphdr.3), [**elf64\_getphdr**(3)](/man/os/elfutils/elf64_getphdr.3), [**elf\_getphdrnum**(3)](/man/os/elfutils/elf_getphdrnum.3), [**gelf\_newphdr**(3)](/man/os/elfutils/gelf_newphdr.3), [**gelf\_update\_phdr**(3)](/man/os/elfutils/gelf_update_phdr.3), [**libelf**(3)](/man/os/elfutils/libelf.3), [**elf**(5)](/man/os/elfutils/elf.5)

# [ATTRIBUTES](#ATTRIBUTES)

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

# [REPORTING BUGS](#REPORTING_BUGS)

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

2025-12-23 Libelf

---

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