GELF_UPDATE_SYMSHNDX(3)
π GELF_UPDATE_SYMSHNDX π
okay bestie, so this one lives in the Libelf Programmer's Manual, and it's GELF_UPDATE_SYMSHNDX(3) β say that three times fast, I dare you π«Ά
β¨ NAME β¨
gelf_update_symshndx β update class-independent symbol information and extended section index in the symbol table π
πΈ SYNOPSIS πΈ
#include <gelf.h>
int gelf_update_symshndx (Elf_Data *symdata, Elf_Data *shndxdata, int ndx, GElf_Sym *sym, Elf32_Word xshndx);
π¦ DESCRIPTION π¦
So what this cutie does: it updates symdata and shndxdata, at index ndx, with the class-independent symbol info from sym plus the section index xshndx. Two-for-one deal, we love to see it π
Real talk on the requirements though β symdata needs to be an Elf_Data pointer for an SHT_SYMTAB or SHT_DYNSYM section, and shndxdata needs to be an Elf_Data pointer for an SHT_SYMTAB_SHNDX section. No mixing and matching, okay? π
Wanna know how many symbols are in your symbol table? Divide the size of symdata by the size of a symbol table entry, easy peasy π And where do you get those numbers?
- The size of
symdatacomes fromsymdata->d_size, or from the corresponding section header'ssh_size. - The size of a symbol table entry comes from
gelf_fsize()withELF_T_SYM, or from the corresponding section header'ssh_entsize.
Now here's the lore, iykyk: an SHT_SYMTAB_SHNDX section shows up in ELF binaries when there are too many sections to fit in an unsigned 16-bit value π When that happens, the st_shndx field of a GElf_Sym gets set to SHN_XINDEX to flag that the symbol's section index is actually chillin' over in the SHT_SYMTAB_SHNDX section. You can grab shndxdata for that section using elf_scnshndx(3), elf_getscn(3), and elf_getdata(3) β the holy trinity β¨
Important, no cap: the number of entries inshndxdatamust be equal to the number of entries insymdata. And entryndxinshndxdatacorresponds to entryndxinsymdata. They're matching, periodt π
π PARAMETERS π
symdataβ Pointer toElf_Datafor a section with typeSHT_SYMTABorSHT_DYNSYM. πshndxdataβ Pointer toElf_Datafor a section with typeSHT_SYMTAB_SHNDX.shndxdatamay beNULL. And ifshndxdataisNULL, thenxshndxmust be zero. Rules are rules, bestie πndxβ Zero-based index of the symbol table entry and the extended section index entry that's getting updated. Zero-based, so the first one is0, not1β don't come for me πsymβ Pointer to a caller-provided symbol table entry. ForELFCLASS32binaries,st_valueandst_sizeshould be able to fit within unsigned 32-bit values. Also,symmust not beNULL. Like, ever. π«xshndxβ The updated extended section index entry to be associated withsym. Must be zero ifshndxdataisNULL. And ifsym->st_shndxis notSHN_XINDEX, thenxshndxshould beSHN_UNDEF. Keep that straight, k? π
π RETURN VALUE π
On success? You get a non-zero value back, and the entries at index ndx in symdata and shndxdata (if it's not NULL) get updated with sym and xshndx, respectively π The sections associated with symdata and shndxdata also get flagged with ELF_F_DIRTY.
On failure? Zero comes back, and elf_errno is set. Sad girl hours π
Weird little plot twist: ifsymisNULL, thenNULLis returned without settingelf_errno. Not a typo, that's just how it is π
π SEE ALSO π
elf_getdata(3), elf_getscn(3), elf_scnshndx(3), gelf_fsize(3), gelf_getsymshndx(3), gelf_update_sym(3), libelf(3), elf(5)
Go read those too, they're all part of the same friend group π«Ά
π ATTRIBUTES π
- Interface:
gelf_update_symshndx() - Attribute: Thread safety
- Value:
MT-Safe
Yup, she's MT-Safe β thread safe and unbothered, main character energy fr fr β¨
π’ REPORTING BUGS π’
Found a bug? Report it to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/ β they wanna hear about it, promise π
okay that's the whole page, you're literally a libelf girlie now, I'm so proud ππ
this was Libelf, dated 2025-12-30, and yes it's still GELF_UPDATE_SYMSHNDX(3) β slay, bye bestie! ππΈ
π¦ 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