mount_setattr.2: Minor tweaks to Christian's patch
[man-pages.git] / man3 / getauxval.3
bloba43e6ffae471f6bde21eab369e18474780eff09b
1 .\" Copyright 2012 Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
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.
7 .\"
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.
12 .\"
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
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" See also https://lwn.net/Articles/519085/
26 .\"
27 .TH GETAUXVAL 3  2021-03-22 "GNU" "Linux Programmer's Manual"
28 .SH NAME
29 getauxval \- retrieve a value from the auxiliary vector
30 .SH SYNOPSIS
31 .nf
32 .B #include <sys/auxv.h>
33 .PP
34 .BI "unsigned long getauxval(unsigned long " type );
35 .fi
36 .SH DESCRIPTION
37 The
38 .BR getauxval ()
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.
43 .PP
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.
47 Given the argument
48 .IR type ,
49 .BR getauxval ()
50 returns the corresponding value.
51 .PP
52 The value returned for each
53 .I type
54 is given in the following list.
55 Not all
56 .I type
57 values are present on all architectures.
58 .TP
59 .BR AT_BASE
60 The base address of the program interpreter (usually, the dynamic linker).
61 .TP
62 .BR AT_BASE_PLATFORM
63 A pointer to a string (PowerPC and MIPS only).
64 On PowerPC, this identifies the real platform; may differ from
65 .BR AT_PLATFORM "."
66 On MIPS,
67 .\" commit e585b768da111f2c2d413de6214e83bbdfee8f22
68 this identifies the ISA level (since Linux 5.7).
69 .TP
70 .BR AT_CLKTCK
71 The frequency with which
72 .BR times (2)
73 counts.
74 This value can also be obtained via
75 .IR sysconf(_SC_CLK_TCK) .
76 .TP
77 .BR AT_DCACHEBSIZE
78 The data cache block size.
79 .TP
80 .BR AT_EGID
81 The effective group ID of the thread.
82 .TP
83 .BR AT_ENTRY
84 The entry address of the executable.
85 .TP
86 .BR AT_EUID
87 The effective user ID of the thread.
88 .TP
89 .BR AT_EXECFD
90 File descriptor of program.
91 .TP
92 .BR AT_EXECFN
93 A pointer to a string containing the pathname used to execute the program.
94 .TP
95 .BR AT_FLAGS
96 Flags (unused).
97 .TP
98 .BR AT_FPUCW
99 Used FPU control word (SuperH architecture only).
100 This gives some information about the FPU initialization
101 performed by the kernel.
103 .BR AT_GID
104 The real group ID of the thread.
106 .BR AT_HWCAP
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
115 .IR /proc/cpuinfo .
117 .BR AT_HWCAP2 " (since glibc 2.18)"
118 Further machine-dependent hints about processor capabilities.
120 .BR AT_ICACHEBSIZE
121 The instruction cache block size.
122 .\" .TP
123 .\" .BR AT_IGNORE
124 .\" .TP
125 .\" .BR AT_IGNOREPPC
126 .\" .TP
127 .\" .BR AT_NOTELF
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.
136 .BR AT_L1D_CACHESIZE
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 .
143 .BR AT_L1I_CACHESIZE
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 .
150 .BR AT_L2_CACHESIZE
151 The L2 cache size.
153 .BR AT_L3_CACHEGEOMETRY
154 Geometry of the L3 cache, encoded as for
155 .BR AT_L1D_CACHEGEOMETRY .
157 .BR AT_L3_CACHESIZE
158 The L3 cache size.
160 .BR AT_PAGESZ
161 The system page size (the same value returned by
162 .IR sysconf(_SC_PAGESIZE) ).
164 .BR AT_PHDR
165 The address of the program headers of the executable.
167 .BR AT_PHENT
168 The size of program header entry.
170 .BR AT_PHNUM
171 The number of program headers.
173 .BR AT_PLATFORM
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
177 .IR rpath
178 values.
180 .BR AT_RANDOM
181 The address of sixteen bytes containing a random value.
183 .BR AT_SECURE
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)).
191 Alternatively,
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.
197 (See also
198 .BR secure_getenv (3).)
200 .BR AT_SYSINFO
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).
204 .BR AT_SYSINFO_EHDR
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.
209 .BR AT_UCACHEBSIZE
210 The unified cache block size.
212 .BR AT_UID
213 The real user ID of the thread.
214 .SH RETURN VALUE
215 On success,
216 .BR getauxval ()
217 returns the value corresponding to
218 .IR type .
220 .I type
221 is not found, 0 is returned.
222 .SH ERRORS
224 .BR ENOENT " (since glibc 2.19)"
225 .\" commit b9ab448f980e296eac21ac65f53783967cc6037b
226 No entry corresponding to
227 .IR type
228 could be found in the auxiliary vector.
229 .SH VERSIONS
231 .BR getauxval ()
232 function was added to glibc in version 2.16.
233 .SH ATTRIBUTES
234 For an explanation of the terms used in this section, see
235 .BR attributes (7).
236 .ad l
239 allbox;
240 lbx lb lb
241 l l l.
242 Interface       Attribute       Value
244 .BR getauxval ()
245 T}      Thread safety   MT-Safe
249 .sp 1
250 .SH CONFORMING TO
251 This function is a nonstandard glibc extension.
252 .SH NOTES
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
265 .B LD_SHOW_AUXV
266 environment variable when running a program:
268 .in +4n
270 $ LD_SHOW_AUXV=1 sleep 1
274 The auxiliary vector of any process can (subject to file permissions)
275 be obtained via
276 .IR /proc/[pid]/auxv ;
278 .BR proc (5)
279 for more information.
280 .SH BUGS
281 Before the addition of the
282 .B ENOENT
283 error in glibc 2.19,
284 there was no way to unambiguously distinguish the case where
285 .I type
286 could not be found from the case where the value corresponding to
287 .I type
288 was zero.
289 .SH SEE ALSO
290 .BR execve (2),
291 .BR secure_getenv (3),
292 .BR vdso (7),
293 .BR ld\-linux.so (8)