---
name: "gelf_getrel"
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_getrel"
---

# gelf\_getrel(3)

retrieve relocation entries as class-independent structures

## NAME

gelf\_getrel, gelf\_getrela - retrieve relocation entries as class-independent structures

## SYNOPSIS

```
#include <gelf.h>
GElf_Rel  *gelf_getrel (Elf_Data *data, int ndx, GElf_Rel  *dst);
GElf_Rela *gelf_getrela(Elf_Data *data, int ndx, GElf_Rela *dst);
```

## DESCRIPTION

The **gelf\_getrel**() and **gelf\_getrela**() functions translate the REL or RELA relocation entry at index *ndx* from *data* into a class-independent representation stored in *\*dst*.

*data* must be the **Elf\_Data** of a section whose type matches the function being called: **SHT\_REL** for **gelf\_getrel**() and **SHT\_RELA** for **gelf\_getrela**().

## PARAMETERS

- *data*

  Pointer to an **Elf\_Data** for a SHT\_REL or SHT\_RELA relocation section.

- *ndx*

  Zero-based index of the relocation entry within *data*.

- *dst*

  Pointer to a caller-provided structure for storing the relocation: **GElf\_Rel** for **gelf\_getrel**() and **GElf\_Rela** for **gelf\_getrela**(). *dst* must not be NULL.

## RETURN VALUE

On success, returns *dst*. On failure, returns NULL and sets elf\_errno.  If *data* is NULL, then NULL is returned without setting elf\_errno.

## SEE ALSO

[**elf\_getdata**(3)](/elf_getdata/3.md), [**gelf\_update\_rel**(3)](/gelf_update_rel/3.md), [**gelf\_update\_rela**(3)](/gelf_update_rela/3.md), [**libelf**(3)](/libelf/3.md), [**elf**(5)](/elf/5.md)

## ATTRIBUTES

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **gelf\_getrel**(), gelf\_getrela**()** | Thread safety | MT-Safe |

## REPORTING BUGS

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