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

# elf64\_getchdr(3)

retrieve the compression header of a section

Part of [elf32\_getchdr(3)](/elf32_getchdr/3.md).

## NAME

**elf32\_getchdr**, **elf64\_getchdr**, **gelf\_getchdr** – retrieve the compression header of a section

## LIBRARY

library “libelf”

## SYNOPSIS

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

*Elf32\_Chdr \**\

**elf32\_getchdr**(*Elf\_Scn \*s*);

*Elf64\_Chdr \**\

**elf64\_getchdr**(*Elf\_Scn \*s*);

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

*GElf\_Chdr \**\

**gelf\_getchdr**(*Elf\_Scn \*scn*, *GElf\_Chdr \*chdr*);

## DESCRIPTION

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

Function **elf32\_getchdr**() retrieves a pointer to an *Elf32\_Chdr* structure. Section descriptor *scn* must be associated with an ELF descriptor of class ELFCLASS32.

Function **elf64\_getchdr**() retrieves a pointer to an *Elf64\_Chdr* structure. Section descriptor *scn* must be associated with an ELF descriptor of class ELFCLASS64.

Function **gelf\_getchdr**() copies the values in the compression header associated with argument *scn* to the structure pointed to be argument *dst*. The *GElf\_Chdr* data structure is described in [gelf(3)](/gelf/3.md).

## RETURN VALUES

Functions **elf32\_getchdr**() and **elf64\_getchdr**() return a valid pointer to the appropriate compression header on success or NULL if an error was encountered.

Function **gelf\_getchdr**() returns argument *dst* if successful, or NULL if an error was encountered.

## ERRORS

These functions may fail with the following errors:

- \[ELF\_E\_INVALID\_SECTION\_FLAGS\]

  Arguments *scn* has invalid flags.

- \[ELF\_E\_INVALID\_SECTION\_TYPE\]

  Argument *scn* has invalid type.

- \[ELF\_E\_NOT\_COMPRESSED\]

  Argument *scn* is not compressed.

## SEE ALSO

[elf(3)](/elf/3.md), [elf\_getscn(3)](/elf_getscn/3.md), [gelf(3)](/gelf/3.md),
