GELF_GETSYM(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_GETSYM โ€” bestie, it's literally the symbol table translator โœจ

okay so this is gelf_getsym from the Libelf Programmer's Manual (that's the GELF_GETSYM(3) bit, if you were wondering ๐ŸŽ€) and honestly? she's an icon. she takes a symbol table entry and gives it back to you in a form that doesn't care what class your ELF is. no cap.


โœจ NAME โœจ

gelf_getsym โ€” grab class-independent symbol info from the symbol table at the index you ask for ๐Ÿฆ‹


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <gelf.h>

GElf_Sym *gelf_getsym (Elf_Data *data, int ndx, GElf_Sym *dst);

๐Ÿ’… DESCRIPTION ๐Ÿ’…

so the vibe is: you've got a symbol table entry at index ndx sitting inside data, and this function translates it into a class-independent representation and drops it into *dst. iconic behaviour. ๐Ÿ’–

data must be the Elf_Data of a section whose type is SHT_SYMTAB or SHT_DYNSYM. that's the rule, periodt.

want to know how many symbols are in the symbol table? math time bestie ๐Ÿงฎ โ€” divide the size of the corresponding section (sh_size or d_size) by the size of one symbol table entry. and where does that size come from? sh_entsize or gelf_fsize(3). you're welcome. โœจ

๐Ÿšจ heads up: if the corresponding elf has more than 64K sections, you should be using gelf_getsymshndx to get a symbol's section index instead. go check gelf_getsymshndx(3) for the details, fr fr.

๐ŸŽ€ PARAMETERS ๐ŸŽ€

  • data โ€” pointer to an Elf_Data of a SHT_SYMTAB or SHT_DYNSYM section. ๐Ÿ’ซ
  • ndx โ€” the zero-based index of the symbol table entry inside data. (zero-based, bestie, not one-based, we don't do that here ๐Ÿ™ˆ)
  • dst โ€” pointer to a structure you provide, where the symbol table entry gets stored. and listen โ€” dst must not be NULL. like, at all. ๐Ÿซถ

โญ RETURN VALUE โญ

slay on success โ†’ returns dst. ๐Ÿ’–

flop on failure โ†’ returns NULL and sets elf_errno. ๐Ÿ˜ญ

BUT. tiny plot twist: if data is NULL, then NULL is returned without setting elf_errno. so don't go blaming the errno for that one, it's innocent. ๐Ÿ‘‘


๐Ÿฆ‹ SEE ALSO ๐Ÿฆ‹


๐ŸŒˆ ATTRIBUTES ๐ŸŒˆ

(sorry bestie, no tables allowed in this format, so here's the tea in list form ๐Ÿ“)

  • Interface: gelf_getsym()
  • Attribute: Thread safety
  • Value: MT-Safe ๐Ÿ”ฅ

๐Ÿ’€ REPORTING BUGS ๐Ÿ’€

found a bug? spill it, don't sit on it:


Libelf ยท 2025-12-29 ยท GELF_GETSYM(3) โ€” that's the whole page babes, go translate some symbols, you ate ๐Ÿ’…โœจ๐Ÿซถ

๐Ÿ“ฆ where this page comes from