ELF_GETARHDR(3)
π ELF_GETARHDR π
okay bestie, this is elf_getarhdr(3), straight out of the Libelf Programmer's Manual. it's the lil function that grabs the archive member header info for you. no cap, it's short but it's mighty. π
β¨ NAME β¨
elf_getarhdr β retrieve archive member header information ποΈ
πΈ SYNOPSIS πΈ
#include <libelf.h>
Elf_Arhdr *elf_getarhdr(Elf *elf);
π¦ DESCRIPTION π¦
so basically it hands you back a Elf_Arhdr * that describes the archive header of the archive member your ELF descriptor is currently pointing at. that's it, that's the vibe. π
the Elf_Arhdr structure is defined like this, and yes you're gonna want to memorise it:
typedef struct {
char *ar_name; /* Name of archive member. */
time_t ar_date; /* File date. */
uid_t ar_uid; /* User ID. */
gid_t ar_gid; /* Group ID. */
mode_t ar_mode; /* File mode. */
int64_t ar_size; /* File size. */
char *ar_rawname; /* Original name of archive member. */
} Elf_Arhdr;
look at all those fields. ar_name, ar_date, ar_uid, ar_gid, ar_mode, ar_size, ar_rawname. iconic lineup fr fr. π
π§ PARAMETERS π§
elfβ an ELF descriptor referring to a member of an archive file. like, it's gotta be a member of an archive, bestie, that's the whole point. π«Ά
π RETURN VALUE π
if elf refers to an archive member, elf_getarhdr() returns a pointer to its archive header. periodt. β¨
β οΈ okay listen, this pointer is valid untilelfor the parent archiveElfdescriptor are closed usingelf_end(). so don't be out here holding onto it after you close stuff, that's giving undefined chaos. π
if elf does not refer to an archive member, or the header cannot be acquired, then NULL is returned. shrug. π
π SEE ALSO π
go read those too, they're all part of the same friend group. π
π ATTRIBUTES π
- Interface:
elf_getarhdr() - Attribute: Thread safety
- Value: MT-safe π₯
π REPORTING BUGS π
found a bug? spill the tea:
- email
<elfutils-devel@sourceware.org> - or hit up
https://sourceware.org/bugzilla/
π cute sign-off π
this lil slice of manpage goodness is from the Libelf manual, and the date on it is 2025-06-06. ok that's the whole page bestie, go get those archive headers, slay, and remember: elf_end() your descriptors or the vibe check will come for you. πβ¨π¦
π¦ 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