GELF_UPDATE_EHDR(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_EHDR πŸ’…

okay bestie, welcome to the Libelf Programmer's Manual πŸŽ€ β€” this one's called gelf_update_ehdr, and it's giving "put my header back where it belongs."


🌸 NAME 🌸

gelf_update_ehdr β€” copy a class-independent ELF header into an ELF descriptor

like, literally what it says on the tin, no cap 🫢


✨ SYNOPSIS ✨

#include <gelf.h>

int gelf_update_ehdr(Elf *elf, GElf_Ehdr *src);

πŸ’– DESCRIPTION πŸ’–

okay so. gelf_update_ehdr() takes the class-independent ELF header from the structure that src points at, and copies it into the ELF descriptor elf. obsessed.

and the way it does it?? the header gets translated as necessary so it matches the class of the underlying object β€” either ELFCLASS32 or ELFCLASS64. it just knows what vibe the object is on πŸ¦‹

but here's the part where you gotta pay attention, bestie: if elf has class ELFCLASS32, then e_entry, e_phoff and e_shoff must be expressible as 32-bit values. like, that's non-negotiable, the math has to math πŸ”₯

also, this function marks the Ehdr dirty β€” see elf_flagehdr(). it's messy on purpose, that's the point πŸ’…


πŸŽ€ PARAMETERS πŸŽ€

  • elf β€” pointer to an ELF descriptor of kind ELF_K_ELF. the main character, obviously.
  • src β€” pointer to a GElf_Ehdr structure holding the caller's desired header contents. Must not be NULL. do NOT test me on this one 😭

⭐ RETURN VALUE ⭐

on success, gelf_update_ehdr() returns a non-zero value. slay. βœ…

on failure, it returns 0 and sets elf_errno so you can go find out what went wrong. πŸ•΅οΈβ€β™€οΈ

and if elf is NULL?? then 0 is returned without setting elf_errno. yeah, no error for you, it just says no πŸ™ˆ


🌈 SEE ALSO 🌈

the whole friend group fr fr 🫢


πŸ‘‘ ATTRIBUTES πŸ‘‘

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

translation: she is MT-Safe, so multiple threads can hang out with her and nobody's gonna have a bad time. iconic behavior, honestly πŸ’œ


πŸ’€ REPORTING BUGS πŸ’€

found a bug? don't suffer in silence bestie, report it to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/. they wanna know, fr fr πŸ“


and that's the whole page!! this one's from Libelf, dated 2025-09-17, and it lives at section 3 of the manual β€” GELF_UPDATE_EHDR(3), periodt. πŸ’–βœ¨πŸ§š

πŸ“¦ where this page comes from