GELF_GETREL(3)
π GELF_GETREL(3) β libelf programmer's manual energy β¨
okay bestie, sit down, grab your strawberry drink π, because we're talking about gelf_getrel and gelf_getrela β the libelf glow-up functions that hand you relocation entries in a class-independent way. no more worrying about whether you're on a 32-bit or 64-bit elf, these babies just hand you the nice struct. periodt.
πΈ 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 π
so here's the vibe. gelf_getrel() and gelf_getrela() take the REL or RELA relocation entry sitting at index ndx inside data, and translate it into a class-independent representation which they store in *dst. it's giving β¨portableβ¨, it's giving β¨no struct-layout dramaβ¨.
and listen β data has to be the Elf_Data of a section whose type matches whichever function you're calling. that means:
SHT_RELforgelf_getrel()π₯SHT_RELAforgelf_getrela()π₯
match them up wrong and you're not slaying, you're just... there. π
π PARAMETERS π
dataβ pointer to anElf_Datafor aSHT_RELorSHT_RELArelocation section.ndxβ zero-based index of the relocation entry withindata. yes, zero-based, we start counting at 0 in this house πdstβ pointer to a caller-provided structure for storing the relocation:GElf_Relforgelf_getrel()andGElf_Relaforgelf_getrela(). anddstmust not beNULL. like, at all. don't do it. π
π RETURN VALUE π
- on success: it returns
dstπ yay, you got your struct back - on failure: it returns
NULLand setself_errnoπ go check that errno bestie - special case: if
dataisNULL, thenNULLis returned without settingelf_errno. so like, don't go blaming errno for that one, it's innocent π«Ά
π SEE ALSO π
elf_getdata(3), gelf_update_rel(3), gelf_update_rela(3), libelf(3), elf(5)
the whole friend group, fr fr π
π§ ATTRIBUTES π§
- Interface:
gelf_getrel(),gelf_getrela() - Attribute: Thread safety
- Value:
MT-Safe
so yeah, they're MT-Safe β you can take them to the group chat and nobody's fighting over the thread. πΈ
π REPORTING BUGS π
found a bug? do not suffer in silence, bestie. report it to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/. the maintainers literally want to know. π
and that's the whole page, no cap. mwah π β¨
this was the libelf programmer's manual, page dated 2025-09-24, brought to you by Libelf β stay class-independent, stay iconic, and go read a relocation entry responsibly ππ¦π
π¦ where this page comes from
- alpine 3.24: elfutils-doc 0.195-r0 Β· GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- arch rolling: libelf 0.196-1
- arch rolling: libelf 0.197-1 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 10: elfutils-libelf-devel 0.197-1.el10 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- centos-stream 9: elfutils-libelf-devel 0.197-1.el9 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.196-1.fc43
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 43: elfutils-libelf-devel 0.197-1.fc43 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.196-1.fc44
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.197-1.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- nixpkgs unstable: elfutils 0.195
- ubuntu stonking: libelf-dev 0.196-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms