1 .\" Copyright 2012 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" See also https://lwn.net/Articles/519085/
27 .TH GETAUXVAL 3 2021-03-22 "GNU" "Linux Programmer's Manual"
29 getauxval \- retrieve a value from the auxiliary vector
32 .B #include <sys/auxv.h>
34 .BI "unsigned long getauxval(unsigned long " type );
39 function retrieves values from the auxiliary vector,
40 a mechanism that the kernel's ELF binary loader
41 uses to pass certain information to
42 user space when a program is executed.
44 Each entry in the auxiliary vector consists of a pair of values:
45 a type that identifies what this entry represents,
46 and a value for that type.
50 returns the corresponding value.
52 The value returned for each
54 is given in the following list.
57 values are present on all architectures.
60 The base address of the program interpreter (usually, the dynamic linker).
63 A pointer to a string (PowerPC and MIPS only).
64 On PowerPC, this identifies the real platform; may differ from
67 .\" commit e585b768da111f2c2d413de6214e83bbdfee8f22
68 this identifies the ISA level (since Linux 5.7).
71 The frequency with which
74 This value can also be obtained via
75 .IR sysconf(_SC_CLK_TCK) .
78 The data cache block size.
81 The effective group ID of the thread.
84 The entry address of the executable.
87 The effective user ID of the thread.
90 File descriptor of program.
93 A pointer to a string containing the pathname used to execute the program.
99 Used FPU control word (SuperH architecture only).
100 This gives some information about the FPU initialization
101 performed by the kernel.
104 The real group ID of the thread.
107 An architecture and ABI dependent bit-mask whose settings
108 indicate detailed processor capabilities.
109 The contents of the bit mask are hardware dependent
110 (for example, see the kernel source file
111 .IR arch/x86/include/asm/cpufeature.h
112 for details relating to the Intel x86 architecture; the value
113 returned is the first 32-bit word of the array described there).
114 A human-readable version of the same information is available via
117 .BR AT_HWCAP2 " (since glibc 2.18)"
118 Further machine-dependent hints about processor capabilities.
121 The instruction cache block size.
129 .\" Kernel commit 98a5f361b8625c6f4841d6ba013bbf0e80d08147
130 .BR AT_L1D_CACHEGEOMETRY
131 Geometry of the L1 data cache, encoded with the cache line size in bytes
132 in the bottom 16 bits and the cache associativity in the next 16 bits.
133 The associativity is such that if N is the 16-bit value,
134 the cache is N-way set associative.
137 The L1 data cache size.
139 .BR AT_L1I_CACHEGEOMETRY
140 Geometry of the L1 instruction cache, encoded as for
141 .BR AT_L1D_CACHEGEOMETRY .
144 The L1 instruction cache size.
146 .BR AT_L2_CACHEGEOMETRY
147 Geometry of the L2 cache, encoded as for
148 .BR AT_L1D_CACHEGEOMETRY .
153 .BR AT_L3_CACHEGEOMETRY
154 Geometry of the L3 cache, encoded as for
155 .BR AT_L1D_CACHEGEOMETRY .
161 The system page size (the same value returned by
162 .IR sysconf(_SC_PAGESIZE) ).
165 The address of the program headers of the executable.
168 The size of program header entry.
171 The number of program headers.
174 A pointer to a string that identifies the hardware platform
175 that the program is running on.
176 The dynamic linker uses this in the interpretation of
181 The address of sixteen bytes containing a random value.
184 Has a nonzero value if this executable should be treated securely.
185 Most commonly, a nonzero value indicates that the process is
186 executing a set-user-ID or set-group-ID binary
187 (so that its real and effective UIDs or GIDs differ from one another),
188 or that it gained capabilities by executing
189 a binary file that has capabilities (see
190 .BR capabilities (7)).
192 a nonzero value may be triggered by a Linux Security Module.
193 When this value is nonzero,
194 the dynamic linker disables the use of certain environment variables (see
195 .BR ld\-linux.so (8))
196 and glibc changes other aspects of its behavior.
198 .BR secure_getenv (3).)
201 The entry point to the system call function in the vDSO.
202 Not present/needed on all architectures (e.g., absent on x86-64).
205 The address of a page containing the virtual Dynamic Shared Object (vDSO)
206 that the kernel creates in order to provide fast implementations of
207 certain system calls.
210 The unified cache block size.
213 The real user ID of the thread.
217 returns the value corresponding to
221 is not found, 0 is returned.
224 .BR ENOENT " (since glibc 2.19)"
225 .\" commit b9ab448f980e296eac21ac65f53783967cc6037b
226 No entry corresponding to
228 could be found in the auxiliary vector.
232 function was added to glibc in version 2.16.
234 For an explanation of the terms used in this section, see
242 Interface Attribute Value
245 T} Thread safety MT-Safe
251 This function is a nonstandard glibc extension.
253 The primary consumer of the information in the auxiliary vector
254 is the dynamic linker,
255 .BR ld\-linux.so (8).
256 The auxiliary vector is a convenient and efficient shortcut
257 that allows the kernel to communicate a certain set of standard
258 information that the dynamic linker usually or always needs.
259 In some cases, the same information could be obtained by system calls,
260 but using the auxiliary vector is cheaper.
262 The auxiliary vector resides just above the argument list and
263 environment in the process address space.
264 The auxiliary vector supplied to a program can be viewed by setting the
266 environment variable when running a program:
270 $ LD_SHOW_AUXV=1 sleep 1
274 The auxiliary vector of any process can (subject to file permissions)
276 .IR /proc/[pid]/auxv ;
279 for more information.
281 Before the addition of the
284 there was no way to unambiguously distinguish the case where
286 could not be found from the case where the value corresponding to
291 .BR secure_getenv (3),