GELF_GETCLASS(3)

πŸ“¦
version 0.197 Β· 2 versions
, in alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu resolute, ubuntu stonking

✨ GELF_GETCLASS ✨

okay bestie, so you know how every ELF file out there is either living that 32-bit life or that 64-bit life? yeah. this little function from the Libelf Programmer's Manual tells you which one you're looking at. it's giving ✨vibe check for binaries✨ and honestly? iconic. πŸŽ€


🌸 NAME 🌸

gelf_getclass β€” bestie, this returns the ELF class (32-bit or 64-bit) for an object πŸ’–


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <gelf.h>

int gelf_getclass(Elf *elf);

like. that's it. one include, one function, one Elf *. slay. πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

so gelf_getclass() returns the class of the ELF object that elf points at. no cap.

if you've got a valid ELF file on your hands, the class is gonna be one of these two gorgeous options:

  • ELFCLASS32 β€” the object is a 32-bit ELF class. tiny. adorable. still valid. πŸ“
  • ELFCLASS64 β€” the object is a 64-bit ELF class. big. powerful. main character energy. πŸ‘‘

and if elf is not denoting a valid ELF object, or the class literally cannot be determined? you get ELFCLASSNONE back. 😭 the void. the nothingness. we don't love that for you but it's the truth.


πŸ”₯ RETURN VALUE πŸ”₯

on success you get ELFCLASS32 or ELFCLASS64. periodt. 🫢

but listen β€” if elf is NULL, or if it doesn't refer to a valid ELF binary with kind ELF_K_ELF, then ELFCLASSNONE is what you're getting back. so uh. check that pointer, bestie. πŸ™ˆ


🌈 SEE ALSO 🌈

go read those too, iykyk. ✨


πŸ’… ATTRIBUTES πŸ’…

  • Interface β€” gelf_getclass()
  • Attribute β€” Thread safety
  • Value β€” MT-unsafe race
⚠️ okay so real talk: MT-unsafe race. that means if you're out here threading this call all willy-nilly, that's a race condition. be careful, queen. πŸ’€

πŸŽ€ REPORTING BUGS πŸŽ€

found a bug? not the cute kind? 😭 report it to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/. they'll love you for it. fr fr. 🫢


and that's the whole page, bestie!! this was Libelf, dated 2025-09-14, brought to you by the Libelf Programmer's Manual β€” go forth and check your classes. mwah. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from