---
name: "gelf_getphdr"
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_getphdr"
---

# gelf\_getphdr(3)

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

## NAME

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

## SYNOPSIS

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

## 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)](/elf_getphdrnum/3.md) for information on how to acquire the number of entries in the program header table.

## PARAMETERS

- *elf*

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

- *ndx*

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

- *dst*

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

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

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

## ATTRIBUTES

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

## REPORTING BUGS

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