GELF_UPDATE_REL(3)
β¨ GELF_UPDATE_REL β bestie's guide to yeeting relocation entries into a section β¨
okay so this is a page from the Libelf Programmer's Manual, and it's about two little functions that are genuinely the moment π
π NAME π
gelf_update_rel, gelf_update_rela β copy class-independent relocation entries into a relocation section
like. they take your cute little struct and put it in the section. that's the whole job. and they ate.
πΈ SYNOPSIS πΈ
#include <gelf.h>
int gelf_update_rel (Elf_Data *data, int ndx, GElf_Rel *src);
int gelf_update_rela(Elf_Data *data, int ndx, GElf_Rela *src);
π DESCRIPTION π
so the way that gelf_update_rel() and gelf_update_rela() work is: they copy a class-independent REL or RELA relocation entry out of *src and drop it into the SHT_REL or SHT_RELA section that's associated with data, at entry index ndx. that's it. that's the function. iconic behaviour, no notes. π«Ά
π¦ PARAMETERS π¦
dataβ theElf_Datafor a relocation section. lowkey important: the section has to havesh_typeSHT_RELif you're callinggelf_update_rel(), orSHT_RELAif you're callinggelf_update_rela(). mismatch = not the vibe.ndxβ the zero-based index of the relocation entry insidedata. yes bestie, zero-based, count from 0 like a normal person.srcβ pointer to the caller-provided source entry: aGElf_Relforgelf_update_rel()and aGElf_Relaforgelf_update_rela().srcmust not be NULL. fr fr, do not do that.
and for ELFCLASS32 binaries, here's the tea π:
r_offsetshould fit in unsigned 32 bits.r_addendshould fit in signed 32 bits.- the
GELF_R_SYMcomponent ofr_infoshould fit in 24 bits. - the
GELF_R_TYPEcomponent should fit in 8 bits.
β RETURN VALUE β
on success, gelf_update_rel() and gelf_update_rela() copy src into data, flag the corresponding section with ELF_F_DIRTY, and return a non-zero value. slay.
on failure, they return 0 and set elf_errno. so check that errno, bestie, it's telling you something.
β οΈ and ifsrcisNULL? then0is returned without settingelf_errno. so like. don't go blaming errno for that one, it's innocent. π
π SEE ALSO π
π ATTRIBUTES π
gelf_update_rel(),gelf_update_rela()β Thread safety:MT-Safe
(no cap, that's the whole table, we're just vibing with it as a bullet list now)
π REPORTING BUGS π
found a bug? tell the people:
- email
<elfutils-devel@sourceware.org> - or go to
https://sourceware.org/bugzilla/
they wanna hear it, genuinely.
and that's the page!! this was GELF_UPDATE_REL(3) from Libelf, dated 2025-09-27, and it's been an absolute pleasure being your manual bestie. go forth and update those relocations responsibly, mwah π
πβ¨
π¦ 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