---
name: "gelf_getcap"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/gelf_getcap"
---

# gelf\_getcap(3)

read and update ELF capability information

## NAME

**gelf\_getcap**, **gelf\_update\_cap** – read and update ELF capability information

## LIBRARY

library “libelf”

## SYNOPSIS

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

*GElf\_Cap \**\

**gelf\_getcap**(*Elf\_Data \*data*, *int ndx*, *GElf\_Cap \*cap*);

*int*\

**gelf\_update\_cap**(*Elf\_Data \*data*, *int ndx*, *GElf\_Cap \*cap*);

## DESCRIPTION

These convenience functions are used to retrieve and update class-dependent *Elf32\_Cap* or *Elf64\_Cap* information.

Argument *data* is an *Elf\_Data* descriptor associated with a section of type SHT\_SUNW\_cap. Argument *ndx* is the index of the entry being retrieved or updated. The class-independent *GElf\_Cap* structure is described in [gelf(3)](/gelf/3.md).

Function **gelf\_getcap**() retrieves the class-dependent entry at index *ndx* in data buffer *data* and copies it to the destination pointed to by argument *cap* after translation to class-independent form.

Function **gelf\_update\_cap**() converts the class-independent entry pointed to by argument *cap* to class-dependent form, and writes it to the entry at index *ndx* in the data buffer described by argument *data*. Function **gelf\_update\_cap**() signals an error if any of the values in the class-independent representation exceeds the representable limits of the target type.

## RETURN VALUES

Function **gelf\_getcap**() returns the value of argument *cap* if successful, or NULL in case of an error. Function **gelf\_update\_cap**() returns a non-zero value if successful, or zero in case of an error.

## ERRORS

These functions may fail with the following errors:

- \[ELF\_E\_ARGUMENT\]

  Arguments *data* or *cap* were NULL.

- \[ELF\_E\_ARGUMENT\]

  Argument *ndx* was less than zero or larger than the number of entries in the data descriptor.

- \[ELF\_E\_ARGUMENT\]

  Data descriptor *data* was not associated with a section of type SHT\_SUNW\_cap.

- \[ELF\_E\_RANGE\]

  A value was not representable in the target type.

- \[ELF\_E\_VERSION\]

  The *Elf\_Data* descriptor denoted by argument *data* is associated with an ELF object with an unsupported version.

## SEE ALSO

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