GELF_FSIZE(3)
π 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β theElfdescriptor, 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 bestiecountβ how many elements of that type. yes, plural, we're doing an array situationversionβ the ELF version. set it toEV_CURRENTbecause 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 oftypemultiplied bycountis greater thanSIZE_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:
- Report bugs to
<elfutils-devel@sourceware.org> - Or hit up:
https://sourceware.org/bugzilla/
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
- 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