GELF_GETREL(3)

πŸ“¦
version 0.197 Β· 2 versions
, in alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixpkgs unstable, ubuntu stonking

πŸ’– 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_REL for gelf_getrel() πŸ”₯
  • SHT_RELA for gelf_getrela() πŸ”₯

match them up wrong and you're not slaying, you're just... there. πŸ™ˆ


πŸŽ€ 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. yes, zero-based, we start counting at 0 in this house πŸ‘‘
  • dst β€” pointer to a caller-provided structure for storing the relocation: GElf_Rel for gelf_getrel() and GElf_Rela for gelf_getrela(). and dst must not be NULL. like, at all. don't do it. πŸ’€

🌈 RETURN VALUE 🌈

  • on success: it returns dst πŸ’– yay, you got your struct back
  • on failure: it returns NULL and sets elf_errno 😭 go check that errno bestie
  • special case: if data is NULL, then NULL is returned without setting elf_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