ELF32_CHECKSUM(3)

πŸ“¦
version 0.197 Β· 2 versions
  • 0.197 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 15.1 Β· freebsd 14.5, freebsd 15.1, nixpkgs unstable
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ELF32_CHECKSUM(3) πŸ’–

okay bestie, so this is a libelf page β€” like, the Libelf Programmer's Manual, section 3, and it's about two little functions that do the exact same thing but for two different flavors of ELF file. no gatekeeping, we're learning this together 🫢


✨ NAME ✨

elf32_checksum, elf64_checksum β€” compute the checksum for a 32-bit or 64-bit ELF object file


✨ SYNOPSIS ✨

#include <libelf.h>

long int elf32_checksum(Elf *elf);
long int elf64_checksum(Elf *elf);

✨ DESCRIPTION ✨

So basically you call this on an ELF object file β€” the one referred to by elf β€” and it hands you back a checksum. iconic. πŸ’…

The checksum is computed from the permanent parts of the ELF file, and the result is repeatable β€” meaning if you run it again on the same file, you get the same number back. no surprises, no chaos, we love consistency 🌸

The way it stays repeatable is the tea though: to make that happen, strippable sections are not included in computing the checksum. and SHT_NOBITS sections are also left out of the calculation. not invited to the party, sorry not sorry πŸ’€

oh and btw? the checksum can be used as a value for DT_CHECKSUM. slay.


✨ PARAMETERS ✨

  • elf β€” the ELF object file for which the checksum is to be computed. that's it. that's the whole vibe.

✨ RETURN VALUE ✨

On success, you get the computed checksum back. πŸŽ‰

If an error occurs, it returns -1 and sets a libelf error code. so like, check that error, bestie, don't just ignore the -1, that's not the moment for denial 😭

Also super important: the checksum is always calculated as a 4-byte value. and if long int happens to be larger than 4 bytes? then the checksum gets extended by padding with zeros. so it fits. no drama. ✨


✨ SEE ALSO ✨


✨ ATTRIBUTES ✨

For an explanation of the terms used in this section, see attributes(7).

  • elf32_checksum(), elf64_checksum() β€” Thread safety β€” MT-Safe πŸ‘‘

(yeah it was a whole table in the original, but we're doing bullets, and the facts are the same, periodt.)


✨ REPORTING BUGS ✨

Found a bug? Report it to <elfutils-devel@sourceware.org> or over at https://sourceware.org/bugzilla/. go off, we appreciate you 🫢


and that's the whole page, bestie!! this was Libelf, dated 2024-08-14, filed under ELF32_CHECKSUM(3) β€” take care of each other and take care of your checksums πŸ’–βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from