ELF_GETARHDR(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

πŸ’– 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 until elf or the parent archive Elf descriptor are closed using elf_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:


πŸŽ€ 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