GELF_FSIZE(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_FSIZE πŸ’–

okay bestie, welcome to the Libelf Programmer's Manual β€” sit down, grab a strawberry, we're gonna talk about how many bytes a thing takes up on disk πŸ“βœ¨


✨ NAME ✨

gelf_fsize β€” the lil function that calculates the file size of an ELF data structure πŸ’…


🌸 SYNOPSIS 🌸

#include <gelf.h>

size_t gelf_fsize (Elf *elf, Elf_Type type, size_t count, unsigned int version);

πŸ¦‹ DESCRIPTION πŸ¦‹

So here's the tea πŸ«– β€” this function returns the number of bytes you need for the on-disk representation of an array of count elements, where the type of those elements is type.

And the number of bytes? It depends on the binary class of the elf you handed it β€” so either ELFCLASS32 or ELFCLASS64, pick your fighter πŸ‘‘

Important vibe check: the on-disk and in-memory representations of Elf_Type are assumed to be the same. No cap. If you wanna know more about Elf_Type, go read libelf(3) β€” it's giving lore ✨


πŸŽ€ PARAMETERS πŸŽ€

  • elf β€” the Elf descriptor, and it's the one deciding which binary class we use to compute the file size. main character energy fr πŸ’…
  • type β€” the ELF data structure whose file size we're calculating. that's the whole point bestie
  • count β€” how many elements of that type. yes, plural, we're doing an array situation
  • version β€” the ELF version. set it to EV_CURRENT because that is literally the only valid value πŸ™ˆ

⭐ RETURN VALUE ⭐

You get back the size in bytes of the specified count and type of data structure. slay πŸ’–

BUT β€” and this is the part where we hold hands 🫢 β€” if version is not set to EV_CURRENT, or if type is not a valid Elf_Type, then you get 0 back and elf_errno gets set. not the vibe, but okay 😭

⚠️ Also real talk: integer overflow can occur if the size of type multiplied by count is greater than SIZE_MAX. be careful out there, bestie πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


🌈 ATTRIBUTES 🌈

  • Interface: gelf_fsize()
  • Attribute: Thread safety
  • Value: MT-Safe πŸ”₯ (she's safe in threads, we love that for her)

πŸ’œ REPORTING BUGS πŸ’œ

Found a bug? Don't suffer in silence, tell the devs bestie:


that's the whole page, you ate it 🍽️✨ this was Libelf, dated 2025-12-22, and you were reading GELF_FSIZE(3) β€” periodt πŸ’…πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from