GELF_GETLIB(3)

✨ GELF_GETLIB(3) ✨

okay bestie, welcome to the Libelf Programmer's Manual πŸ’– this one's short, sweet, and honestly kinda niche, but you're gonna eat it up.


🌸 NAME 🌸

gelf_getlib β€” grab a prelink library out of the table at whatever index you want 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <gelf.h>

GElf_Lib *gelf_getlib (Elf_Data *data, int ndx, GElf_Lib *dst);

like... that's the whole vibe. three args, one struct pointer back. iconic πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: you pull a prelink library table entry out of data at index ndx, and it gets stored into that class-independent representation that dst is pointing at. that's it. that's the function ✨

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. no cap.

ngl, SHT_GNU_LIBLIST sections are the ones the prelink utility uses. if you want the deep lore, it lives at https://sourceware.org/gnu-gabi/prelink.txt πŸ‘‘ go read it, i'll wait.


πŸ’œ PARAMETERS πŸ’œ

  • data β€” pointer to an Elf_Data of a section with type SHT_GNU_LIBLIST. and yeah, data->d_type should be ELF_T_LIB. that's the assignment, bestie.
  • ndx β€” the zero-based index of the prelink library table entry you're asking for, counted within data. zero-based!! don't come at me with a 1, i will know πŸ™ˆ
  • dst β€” pointer to a caller-provided GElf_Lib structure where the requested prelink library table entry gets stored. must not be NULL. that's not a suggestion, that's a rule πŸ’€

🌈 RETURN VALUE 🌈

on success? it updates dst with the prelink library table entry you asked for and returns dst. slay. ✨

on failure? it returns NULL and sets elf_errno. periodt.

ok but the special case: if data is NULL, then NULL gets returned without setting elf_errno. so like, don't go checking elf_errno for that one, you'll just be confused and i'm protecting you from that 🫢

πŸ“ SEE ALSO πŸ“


⭐ ATTRIBUTES ⭐

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

so yeah, it's MT-Safe. go off, threads. 🧚


πŸ’€ REPORTING BUGS πŸ’€

found something cursed? report bugs to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/. they wanna hear it, fr fr.


πŸ‘‘ HISTORY πŸ‘‘

gelf_getlib first appeared in elfutils 0.95. and heads up bestie: 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 it doesn't exist... that's why. not your fault, not mine, it's just the lore 😭


and that's the whole page!! πŸ’– this was the Libelf manual, page GELF_GETLIB(3), dated 2025-12-31. ty for coming to my ted talk, go forth and read your prelink library tables responsibly πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from