GELF_UPDATE_REL(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_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 β€” the Elf_Data for a relocation section. lowkey important: the section has to have sh_type SHT_REL if you're calling gelf_update_rel(), or SHT_RELA if you're calling gelf_update_rela(). mismatch = not the vibe.
  • ndx β€” the zero-based index of the relocation entry inside data. yes bestie, zero-based, count from 0 like a normal person.
  • src β€” pointer to the caller-provided source entry: a GElf_Rel for gelf_update_rel() and a GElf_Rela for gelf_update_rela(). src must not be NULL. fr fr, do not do that.

and for ELFCLASS32 binaries, here's the tea πŸ“:

  • r_offset should fit in unsigned 32 bits.
  • r_addend should fit in signed 32 bits.
  • the GELF_R_SYM component of r_info should fit in 24 bits.
  • the GELF_R_TYPE component 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 if src is NULL? then 0 is returned without setting elf_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:

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