ELF_GETBASE(3)
π NAME π
elf_getbase β bestie, this is the lil' function that tells you the base offset of an ELF object file. That's it. That's the whole job. She's simple, she's reliable, she's giving minimal effort, maximum impact β¨
πΈ SYNOPSIS πΈ
#include <libelf.h>
int64_t elf_getbase(Elf *elf);
π¦ DESCRIPTION π¦
okay so picture this: you hand elf_getbase an ELF descriptor β we're calling her elf β and she hands you back the file offset of the very first byte of that descriptor. Like, the actual "she starts right here" coordinate in the file. π
Now here's the plot twist π β if elf is a member of an archive, meaning its ELF kind is ELF_K_AR, then the base offset she gives you is the offset of the ELF object within the archive. So it's the position of the member inside the big archive container, not some absolute file position, iykyk.
And for every other ELF object type? The base offset is just 0. Simple. Clean. No drama. π
π PARAMETERS π
elfβ the ELF descriptor. That's the one and only thing you're passing in here, bestie. Just the descriptor. π«Ά
β¨ RETURN VALUE β¨
So what do you actually get back? Here's the vibe check:
- If elf's ELF kind is
ELF_K_AR, you get the base offset of elf. π - Otherwise, you get
0. - And if elf is
NULL? You get-1. Yeah. She said no. π
π SEE ALSO π
elf_getaroff(3)elf_rawelf(3)libelf(3)elf(5)
go read those too, they're all part of the same friend group fr fr π§
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7).
elf_getbase()β Thread safety:MT-Safeπ
π REPORTING BUGS π
Found a bug? Not the vibe, but okay, spill π β report it to <elfutils-devel@sourceware.org> or hit up https://sourceware.org/bugzilla/.
okay that's the whole page, you ate that, periodt π
β¨ this was Libelf, dated 2025-03-31, and you were reading ELF_GETBASE(3) β go forth and compute those offsets, bestie π«ΆπΈ
π¦ where this page comes from
- alpine 3.23: elfutils-doc 0.194-r0 Β· GPL-3.0-or-later AND ( GPL-2.0-or-later OR LGPL-3.0-or-later )
- 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.194-5.fc44 Β· GPL-2.0-or-later OR LGPL-3.0-or-later
- fedora 44: elfutils-libelf-devel 0.194-5.fc44 Β· 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
- nixos 26.05: elfutils 0.194
- nixpkgs unstable: elfutils 0.195
- ubuntu resolute: libelf-dev 0.194-4 Β· GPL-3.0-or-later
- 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