gelf_getshdr(3)

gelf_getshdr3

Retrieve the class-dependent section header

Usage

#include <libelf.h>

Elf32_Shdr *

elf32_getshdr(Elf_Scn *scn);

Elf64_Shdr *

elf64_getshdr(Elf_Scn *scn);

#include <gelf.h>

GElf_Shdr *

gelf_getshdr(Elf_Scn *scn, GElf_Shdr *shdr);

Library

library “libelf”

Overview

These functions return a pointer to the ELF Section Header data structure associated with section descriptor scn.

Function elf32_getshdr() retrieves a pointer to an Elf32_Shdr structure. Section descriptor scn must be associated with an ELF descriptor of class ELFCLASS32.

Function elf64_getshdr() retrieves a pointer to an Elf64_Shdr structure. Section descriptor scn must be associated with an ELF descriptor of class ELFCLASS64.

Function gelf_getshdr() copies the values in the section header associated with argument scn to the structure pointed to be argument dst. The GElf_Shdr data structure is described in gelf(3).

Return values

Functions elf32_getshdr() and elf64_getshdr() return a valid pointer to the appropriate section header on success or NULL if an error was encountered.

Function gelf_getshdr() returns argument dst if successful, or NULL if an error was encountered.

Errors

These functions may fail with the following errors:

[ELF_E_ARGUMENT]

Arguments scn or shdr were NULL.

[ELF_E_ARGUMENT]

Argument scn was not associated a descriptor for an ELF object.

[ELF_E_CLASS]

The ELF class associated with the section descriptor scn did not match the class expected by the API.

Releases

44 releases since FreeBSD 7.0-RELEASE; the text changed 20 times.

  1. 7.0
  2. 7.1
  3. 7.2
  4. 7.3
  5. 7.4
  6. 8.0
  7. 8.1
  8. 8.2
  9. 8.3
  10. 8.4
  11. 9.0
  12. 9.1
  13. 9.2
  14. 9.3
  15. 10.0
  16. 10.1
  17. 10.2
  18. 10.3
  19. 10.4
  20. 11.0–12.0
  21. 12.1–16.0

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.