GELF_UPDATE_SHDR(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_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 class ELFCLASS32, then the struct members of src must 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 type Elf_Scn. this is the one getting updated, the main character fr.
  • src β€” a pointer to a GElf_Shdr structure 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: if scn or src are NULL, then 0 is returned without setting elf_errno. so don't go checking elf_errno for 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 🫢


πŸŽ€ 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