GELF_CHECKSUM(3)
β¨ GELF_CHECKSUM(3) β¨
okay so bestie, welcome to the Libelf Programmer's Manual π we're doing gelf_checksum today and honestly? it's a lil cutie. let's get into it π«Ά
π NAME π
gelf_checksum β compute the checksum for an ELF object file
πΈ SYNOPSIS πΈ
#include <gelf.h>
long int gelf_checksum (Elf *elf);
π¦ DESCRIPTION π¦
So you've got this ELF object file, right, and it's referred to by elf. This function computes a checksum for it. That's the whole job. Iconic, lowkey.
It's basically a wrapper, bestie β it acts as a wrapper around elf32_checksum() and elf64_checksum(). The binary class of elf is what decides which one gets called, automatically. You don't have to pick, it just knows. main character energy tbh π
Now, the checksum itself is computed from permanent parts of the ELF file, and the result is repeatable. That repeatability is the whole point, so listen up: to keep it repeatable, strippable sections are NOT included when computing the checksum. SHT_NOBITS sections are also not included. Not invited to the party. π«
And what's it for? You can use this checksum as a value for DT_CHECKSUM. periodt.
π PARAMETERS π
elfβ the ELF object file for which the checksum is to be computed. that's the one. that's the whole parameter. π
β RETURN VALUE β
- On success β it returns the computed checksum π
- On failure β it returns
-1and setself_errno. - Special lil edge case: if
elfisNULL, then-1is returned without settingelf_errno. yeah. it just does that. π
Also important, no cap: the checksum is always calculated as a 4-byte value. If long int happens to be larger than 4 bytes, then the checksum gets extended by padding with zeros. So you're not getting extra checksum, you're getting extra zeros. π«Ά
π SEE ALSO π
π ATTRIBUTES π
gelf_checksum()β Thread safety βMT-Safe
(yes bestie, she's thread safe. go wild. β¨)
π REPORTING BUGS π
Found a bug? Don't suffer in silence, tell the people:
- Report bugs to
<elfutils-devel@sourceware.org> - or hit up
https://sourceware.org/bugzilla/
that's the whole page, bestie β every flag, every caveat, every vibe. go forth and checksum responsibly πβ¨
β from the Libelf manual, dated 2025-12-31, page GELF_CHECKSUM(3), signing off ππ
π¦ 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