1 .\" Copyright 2012 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" See also https://lwn.net/Articles/519085/
7 .TH GETAUXVAL 3 2021-08-27 "GNU" "Linux Programmer's Manual"
9 getauxval \- retrieve a value from the auxiliary vector
12 .RI ( libc ", " \-lc )
15 .B #include <sys/auxv.h>
17 .BI "unsigned long getauxval(unsigned long " type );
22 function retrieves values from the auxiliary vector,
23 a mechanism that the kernel's ELF binary loader
24 uses to pass certain information to
25 user space when a program is executed.
27 Each entry in the auxiliary vector consists of a pair of values:
28 a type that identifies what this entry represents,
29 and a value for that type.
33 returns the corresponding value.
35 The value returned for each
37 is given in the following list.
40 values are present on all architectures.
43 The base address of the program interpreter (usually, the dynamic linker).
46 A pointer to a string (PowerPC and MIPS only).
47 On PowerPC, this identifies the real platform; may differ from
50 .\" commit e585b768da111f2c2d413de6214e83bbdfee8f22
51 this identifies the ISA level (since Linux 5.7).
54 The frequency with which
57 This value can also be obtained via
58 .IR sysconf(_SC_CLK_TCK) .
61 The data cache block size.
64 The effective group ID of the thread.
67 The entry address of the executable.
70 The effective user ID of the thread.
73 File descriptor of program.
76 A pointer to a string containing the pathname used to execute the program.
82 Used FPU control word (SuperH architecture only).
83 This gives some information about the FPU initialization
84 performed by the kernel.
87 The real group ID of the thread.
90 An architecture and ABI dependent bit-mask whose settings
91 indicate detailed processor capabilities.
92 The contents of the bit mask are hardware dependent
93 (for example, see the kernel source file
94 .I arch/x86/include/asm/cpufeature.h
95 for details relating to the Intel x86 architecture; the value
96 returned is the first 32-bit word of the array described there).
97 A human-readable version of the same information is available via
100 .BR AT_HWCAP2 " (since glibc 2.18)"
101 Further machine-dependent hints about processor capabilities.
104 The instruction cache block size.
112 .\" Kernel commit 98a5f361b8625c6f4841d6ba013bbf0e80d08147
113 .B AT_L1D_CACHEGEOMETRY
114 Geometry of the L1 data cache, encoded with the cache line size in bytes
115 in the bottom 16 bits and the cache associativity in the next 16 bits.
116 The associativity is such that if N is the 16-bit value,
117 the cache is N-way set associative.
120 The L1 data cache size.
122 .B AT_L1I_CACHEGEOMETRY
123 Geometry of the L1 instruction cache, encoded as for
124 .BR AT_L1D_CACHEGEOMETRY .
127 The L1 instruction cache size.
129 .B AT_L2_CACHEGEOMETRY
130 Geometry of the L2 cache, encoded as for
131 .BR AT_L1D_CACHEGEOMETRY .
136 .B AT_L3_CACHEGEOMETRY
137 Geometry of the L3 cache, encoded as for
138 .BR AT_L1D_CACHEGEOMETRY .
144 The system page size (the same value returned by
145 .IR sysconf(_SC_PAGESIZE) ).
148 The address of the program headers of the executable.
151 The size of program header entry.
154 The number of program headers.
157 A pointer to a string that identifies the hardware platform
158 that the program is running on.
159 The dynamic linker uses this in the interpretation of
164 The address of sixteen bytes containing a random value.
167 Has a nonzero value if this executable should be treated securely.
168 Most commonly, a nonzero value indicates that the process is
169 executing a set-user-ID or set-group-ID binary
170 (so that its real and effective UIDs or GIDs differ from one another),
171 or that it gained capabilities by executing
172 a binary file that has capabilities (see
173 .BR capabilities (7)).
175 a nonzero value may be triggered by a Linux Security Module.
176 When this value is nonzero,
177 the dynamic linker disables the use of certain environment variables (see
178 .BR ld\-linux.so (8))
179 and glibc changes other aspects of its behavior.
181 .BR secure_getenv (3).)
184 The entry point to the system call function in the vDSO.
185 Not present/needed on all architectures (e.g., absent on x86-64).
188 The address of a page containing the virtual Dynamic Shared Object (vDSO)
189 that the kernel creates in order to provide fast implementations of
190 certain system calls.
193 The unified cache block size.
196 The real user ID of the thread.
200 returns the value corresponding to
204 is not found, 0 is returned.
207 .BR ENOENT " (since glibc 2.19)"
208 .\" commit b9ab448f980e296eac21ac65f53783967cc6037b
209 No entry corresponding to
211 could be found in the auxiliary vector.
215 function was added to glibc in version 2.16.
217 For an explanation of the terms used in this section, see
225 Interface Attribute Value
228 T} Thread safety MT-Safe
234 This function is a nonstandard glibc extension.
236 The primary consumer of the information in the auxiliary vector
237 is the dynamic linker,
238 .BR ld\-linux.so (8).
239 The auxiliary vector is a convenient and efficient shortcut
240 that allows the kernel to communicate a certain set of standard
241 information that the dynamic linker usually or always needs.
242 In some cases, the same information could be obtained by system calls,
243 but using the auxiliary vector is cheaper.
245 The auxiliary vector resides just above the argument list and
246 environment in the process address space.
247 The auxiliary vector supplied to a program can be viewed by setting the
249 environment variable when running a program:
253 $ LD_SHOW_AUXV=1 sleep 1
257 The auxiliary vector of any process can (subject to file permissions)
259 .IR /proc/[pid]/auxv ;
262 for more information.
264 Before the addition of the
267 there was no way to unambiguously distinguish the case where
269 could not be found from the case where the value corresponding to
274 .BR secure_getenv (3),