getauxval(3)

๐Ÿ’– getauxval(3) โ€” Library Functions Manual ๐Ÿ’–

okay bestie, listen up. this is getauxval(3) from the Library Functions Manual, and it's lowkey one of the most underrated little functions in libc. we're gonna go through it together, no cap. ๐Ÿซถ


โœจ NAME โœจ

getauxval โ€” retrieve a value from the auxiliary vector

๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc) โ€” the classic. the OG. the one you already linked against. ๐Ÿ’…

๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <sys/auxv.h>

unsigned long getauxval(unsigned long type);

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so. getauxval() pulls values out of the auxiliary vector, which is this whole mechanism where the kernel's ELF binary loader hands certain info over to user space the moment a program gets executed. it's giving backstage pass energy. โœจ

every entry in the auxiliary vector is literally just a pair of values: a type that says what this entry is about, and a value for that type. you hand it a type, it hands you back the matching value. simple as that, fr fr.

here's what you get for each type. heads up though: not all type values are present on all architectures, so don't come for me if your box doesn't have one. ๐Ÿ’€

  • AT_BASE โ€” the base address of the program interpreter (usually, the dynamic linker).
  • AT_BASE_PLATFORM โ€” a pointer to a string (PowerPC and MIPS only). On PowerPC, this identifies the real platform; may differ from AT_PLATFORM. On MIPS, this identifies the ISA level (since Linux 5.7).
  • AT_CLKTCK โ€” the frequency with which times(2) counts. this value can also be obtained via sysconf(_SC_CLK_TCK).
  • AT_DCACHEBSIZE โ€” the data cache block size.
  • AT_EGID โ€” the effective group ID of the thread.
  • AT_ENTRY โ€” the entry address of the executable.
  • AT_EUID โ€” the effective user ID of the thread.
  • AT_EXECFD โ€” file descriptor of program.
  • AT_EXECFN โ€” a pointer to a string containing the pathname used to execute the program.
  • AT_FLAGS โ€” flags (unused).
  • AT_FPUCW โ€” used FPU control word (SuperH architecture only). this gives some information about the FPU initialization performed by the kernel.
  • AT_GID โ€” the real group ID of the thread.
  • AT_HWCAP โ€” an architecture and ABI dependent bit-mask whose settings indicate detailed processor capabilities. the contents of the bit mask are hardware dependent (for example, see the kernel source file arch/x86/include/asm/cpufeature.h for details relating to the Intel x86 architecture; the value returned is the first 32-bit word of the array described there). a human-readable version of the same information is available via /proc/cpuinfo.
  • AT_HWCAP2 (since glibc 2.18) โ€” further machine-dependent hints about processor capabilities.
  • AT_ICACHEBSIZE โ€” the instruction cache block size.
  • AT_L1D_CACHEGEOMETRY โ€” geometry of the L1 data cache, encoded with the cache line size in bytes in the bottom 16 bits and the cache associativity in the next 16 bits. the associativity is such that if N is the 16-bit value, the cache is N-way set associative.
  • AT_L1D_CACHESIZE โ€” the L1 data cache size.
  • AT_L1I_CACHEGEOMETRY โ€” geometry of the L1 instruction cache, encoded as for AT_L1D_CACHEGEOMETRY.
  • AT_L1I_CACHESIZE โ€” the L1 instruction cache size.
  • AT_L2_CACHEGEOMETRY โ€” geometry of the L2 cache, encoded as for AT_L1D_CACHEGEOMETRY.
  • AT_L2_CACHESIZE โ€” the L2 cache size.
  • AT_L3_CACHEGEOMETRY โ€” geometry of the L3 cache, encoded as for AT_L1D_CACHEGEOMETRY.
  • AT_L3_CACHESIZE โ€” the L3 cache size.
  • AT_PAGESZ โ€” the system page size (the same value returned by sysconf(_SC_PAGESIZE)).
  • AT_PHDR โ€” the address of the program headers of the executable.
  • AT_PHENT โ€” the size of program header entry.
  • AT_PHNUM โ€” the number of program headers.
  • AT_PLATFORM โ€” a pointer to a string that identifies the hardware platform that the program is running on. the dynamic linker uses this in the interpretation of rpath values.
  • AT_RANDOM โ€” the address of sixteen bytes containing a random value.
  • AT_SECURE โ€” has a nonzero value if this executable should be treated securely. most commonly, a nonzero value indicates that the process is executing a set-user-ID or set-group-ID binary (so that its real and effective UIDs or GIDs differ from one another), or that it gained capabilities by executing a binary file that has capabilities (see capabilities(7)). alternatively, a nonzero value may be triggered by a Linux Security Module. when this value is nonzero, the dynamic linker disables the use of certain environment variables (see ld-linux.so(8)) and glibc changes other aspects of its behavior. (See also secure_getenv(3).)
  • AT_SYSINFO โ€” the entry point to the system call function in the vDSO. not present/needed on all architectures (e.g., absent on x86-64).
  • AT_SYSINFO_EHDR โ€” the address of a page containing the virtual Dynamic Shared Object (vDSO) that the kernel creates in order to provide fast implementations of certain system calls.
  • AT_UCACHEBSIZE โ€” the unified cache block size.
  • AT_UID โ€” the real user ID of the thread.

๐ŸŒˆ RETURN VALUE ๐ŸŒˆ

on success, getauxval() returns the value corresponding to type. and if type isn't found? it returns 0. yeah. we'll talk about that in BUGS, bestie, don't worry. ๐Ÿ™ˆ

๐Ÿ˜ญ ERRORS ๐Ÿ˜ญ

  • ENOENT (since glibc 2.19) โ€” no entry corresponding to type could be found in the auxiliary vector.

๐Ÿ‘‘ ATTRIBUTES ๐Ÿ‘‘

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

  • Interface: getauxval()
  • Attribute: Thread safety
  • Value: MT-Safe

so yeah, it's MT-Safe โ€” go off, multi-threaded icon. ๐Ÿ”ฅ

โญ STANDARDS โญ

GNU.

๐Ÿ’œ HISTORY ๐Ÿ’œ

glibc 2.16.

๐Ÿงš NOTES ๐Ÿงš

the primary consumer of the information in the auxiliary vector is the dynamic linker, ld-linux.so(8). the auxiliary vector is a convenient and efficient shortcut that allows the kernel to communicate a certain set of standard information that the dynamic linker usually or always needs. in some cases, the same information could be obtained by system calls, but using the auxiliary vector is cheaper. it's the express lane, basically. ๐ŸŽ€

the auxiliary vector resides just above the argument list and environment in the process address space. and here's the fun part โ€” you can actually look at the auxiliary vector supplied to a program by setting the LD_SHOW_AUXV environment variable when you run it:

$ LD_SHOW_AUXV=1 sleep 1

also, the auxiliary vector of any process can (subject to file permissions) be obtained via /proc/pid/auxv; see proc(5) for more information. go peek, it's your right. ๐Ÿ‘€

๐Ÿ’€ BUGS ๐Ÿ’€

before the addition of the ENOENT error in glibc 2.19, there was no way to unambiguously distinguish the case where type could not be found from the case where the value corresponding to type was zero. so if you're on ancient glibc and you get a 0 back, that's a whole mystery novel. genuinely can't tell those apart, no cap. ๐Ÿ˜ญ

๐Ÿซถ SEE ALSO ๐Ÿซถ

execve(2), secure_getenv(3), vdso(7), ld-linux.so(8)


and that's the whole vibe check, bestie. this little page came to you from Linux man-pages 6.20, dated 2026-02-08, and it's the getauxval(3) entry โ€” go forth and read your own auxiliary vector, you absolute main character. ๐Ÿ’…โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms