GELF\_GETREL(3) Libelf Programmer's Manual GELF\_GETREL(3)

# [NAME](#NAME)

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

# [SYNOPSIS](#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](#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](#PARAMETERS)

[*data*](#data)

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

[*ndx*](#ndx)

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

[*dst*](#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](#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](#SEE_ALSO)

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

# [ATTRIBUTES](#ATTRIBUTES)

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

# [REPORTING BUGS](#REPORTING_BUGS)

Report bugs to &lt;elfutils-devel@sourceware.org&gt; or https://sourceware.org/bugzilla/.

2025-09-24 Libelf

---

Document: gelf_getrela(3) from elfutils 0.196-r0 (Chainguard OS)
Source: https://sourceware.org/git/elfutils.git
