GELF_UPDATE_SHDR(3)
π GELF_UPDATE_SHDR π
okay bestie, so this is a page from the Libelf Programmer's Manual β it's gelf_update_shdr(3), and it's genuinely one of the most useful little functions in the elfutils-adjacent libelf world. sit with me, we're gonna talk about section headers π
β¨ NAME β¨
gelf_update_shdr β copy a class-independent section header into a section descriptor. that's it, that's the whole vibe. one job, does it well, slay π
πΈ SYNOPSIS πΈ
#include <gelf.h>
int gelf_update_shdr(Elf_Scn *scn, GElf_Shdr *src);
π¦ DESCRIPTION π¦
so here's the tea, bestie β
gelf_update_shdr() copies the class-independent section header that src points at into the section descriptor scn. simple. iconic. no notes.
but here's the part where it gets β¨smartβ¨ β the section header gets translated as needed so it matches the class of the underlying ELF object, and that class is either ELFCLASS32 or ELFCLASS64. so it just fits wherever it's going.
β οΈ and listen, this one matters: if the underlying ELF object has classELFCLASS32, then the struct members ofsrcmust fit into 32-bit field values. no cap. if they don't fitβ¦ that's not a good time for anybody π
π PARAMETERS π
scnβ a pointer to a section descriptor of typeElf_Scn. this is the one getting updated, the main character fr.srcβ a pointer to aGElf_Shdrstructure holding your desired section header contents. your vision, your dreams, your struct π«Ά
π RETURN VALUE π
okay so on success, gelf_update_shdr() returns a non-zero value β and it marks scn with the ELF_F_DIRTY flag. it's giving "noted, changed, flag raised" π
on failure, this function returns 0 and elf_errno gets set. classic.
π special case alert: ifscnorsrcareNULL, then 0 is returned without settingelf_errno. so don't go checkingelf_errnofor that one, bestie, it'll be a whole lot of nothing.
π₯ SEE ALSO π₯
(the whole friend group, honestly. go read them, iykyk)
β ATTRIBUTES β
- Interface:
gelf_update_shdr() - Attribute: Thread safety
- Value:
MT-Safe
so yeah β gelf_update_shdr() is MT-Safe, aka it can hang out in multiple threads at once and not cause drama β¨π§
π REPORTING BUGS π
found a bug? don't be shy, tell the devs π«Ά
- email: <elfutils-devel@sourceware.org>
- or file it at:
https://sourceware.org/bugzilla/
π sign-off π
this page is from Libelf, dated 2025-09-23, and it's the gelf_update_shdr(3) manual page β go forth and update those section headers, bestie, you're gonna eat πβ¨πΈπ¦π
π¦ 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