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 fromAT_PLATFORM. On MIPS, this identifies the ISA level (since Linux 5.7).AT_CLKTCKโ the frequency with whichtimes(2)counts. this value can also be obtained viasysconf(_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 filearch/x86/include/asm/cpufeature.hfor 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 forAT_L1D_CACHEGEOMETRY.AT_L1I_CACHESIZEโ the L1 instruction cache size.AT_L2_CACHEGEOMETRYโ geometry of the L2 cache, encoded as forAT_L1D_CACHEGEOMETRY.AT_L2_CACHESIZEโ the L2 cache size.AT_L3_CACHEGEOMETRYโ geometry of the L3 cache, encoded as forAT_L1D_CACHEGEOMETRY.AT_L3_CACHESIZEโ the L3 cache size.AT_PAGESZโ the system page size (the same value returned bysysconf(_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 (seecapabilities(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 (seeld-linux.so(8)) and glibc changes other aspects of its behavior. (See alsosecure_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
- Copyright 2012, Michael Kerrisk <mtk.manpages@gmail.com>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms