GELF_UPDATE_LIB(3)

πŸ’– GELF_UPDATE_LIB(3) πŸ’–

okay bestie, so we're in the Libelf Programmer's Manual and today's main character is gelf_update_lib β€” no cap, she's literally the girl who writes your prelink library entry into the table. let's get into it 🫢


✨ NAME ✨

gelf_update_lib</p> β€” update a prelink library entry in the table, at whatever index you point at. slay.


✨ SYNOPSIS ✨

#include <gelf.h>

int gelf_update_lib (Elf_Data *data, int ndx, GElf_Lib *src);

✨ DESCRIPTION ✨

So what she actually does: she copies a class-independent prelink library table entry out of src and into the SHT_GNU_LIBLIST section that's associated with data, at index ndx. it's giving copy-paste but make it elfutils πŸ’…

data must be an Elf_Data* that's associated with a section of type SHT_GNU_LIBLIST. and data->d_type should be ELF_T_LIB. like, that's the vibe check.

SHT_GNU_LIBLIST sections are the ones used by the prelink utility. if you wanna know more, go read https://sourceware.org/gnu-gabi/prelink.txt β€” it's right there, i'm not gonna gatekeep. 🌸


✨ PARAMETERS ✨

  • data β€” a pointer to an Elf_Data that's associated with a section of type SHT_GNU_LIBLIST. data->d_type should be ELF_T_LIB. periodt.
  • ndx β€” the zero-based index of the prelink library table entry you wanna update, inside data. zero-based, bestie, we start counting at 0 in this house πŸŽ€
  • src β€” a pointer to a caller-provided prelink library table entry. and src must not be NULL. do not test her. 🚫

✨ RETURN VALUE ✨

On success? she returns a non-zero value, and she's updated the prelink library table entry at index ndx in data. also, the section associated with data gets flagged with ELF_F_DIRTY β€” that's her lil stamp of "yes i touched this" ✨

On failure, she returns zero and sets elf_errno. and here's the lil edge case: if data is NULL, then zero is returned and elf_errno is not set. iconic behaviour honestly.


✨ SEE ALSO ✨

go read those too, they're the supporting cast πŸ¦‹


✨ ATTRIBUTES ✨

  • Interface: gelf_update_lib()
  • Attribute: Thread safety
  • Value: MT-Safe

so yeah, she's MT-Safe, you can bring her to the group hang 🫢


✨ REPORTING BUGS ✨

found a bug? don't suffer in silence, tell the girlies:


✨ HISTORY ✨

gelf_update_lib first appeared in elfutils 0.95 ⭐

and listen β€” this function is an elfutils libelf extension, which means it may not be available in other libelf implementations. so if you port your code somewhere else and she ghosted you... that's why. πŸ’€


okay that's the whole page, you ate it, you understood it, you're basically a libelf girlie now πŸ‘‘

sending you off with the deets: this was Libelf, dated 2025-12-31, filed under GELF_UPDATE_LIB(3) β€” mwah, go update some tables bestie πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from