1GETAUXVAL(3) Linux Programmer's Manual GETAUXVAL(3)
2
3
4
6 getauxval - retrieve a value from the auxiliary vector
7
9 #include <sys/auxv.h>
10
11 unsigned long getauxval(unsigned long type);
12
14 The getauxval() function retrieves values from the auxiliary vector, a
15 mechanism that the kernel's ELF binary loader uses to pass certain
16 information to user space when a program is executed.
17
18 Each entry in the auxiliary vector consists of a pair of values: a type
19 that identifies what this entry represents, and a value for that type.
20 Given the argument type, getauxval() returns the corresponding value.
21
22 The value returned for each type is given in the following list. Not
23 all type values are present on all architectures.
24
25 AT_BASE
26 The base address of the program interpreter (usually, the
27 dynamic linker).
28
29 AT_BASE_PLATFORM
30 A pointer to a string identifying the real platform; may differ
31 from AT_PLATFORM (PowerPC only).
32
33 AT_CLKTCK
34 The frequency with which times(2) counts. This value can also
35 be obtained via sysconf(_SC_CLK_TCK).
36
37 AT_DCACHEBSIZE
38 The data cache block size.
39
40 AT_EGID
41 The effective group ID of the thread.
42
43 AT_ENTRY
44 The entry address of the executable.
45
46 AT_EUID
47 The effective user ID of the thread.
48
49 AT_EXECFD
50 File descriptor of program.
51
52 AT_EXECFN
53 A pointer to a string containing the pathname used to execute
54 the program.
55
56 AT_FLAGS
57 Flags (unused).
58
59 AT_FPUCW
60 Used FPU control word (SuperH architecture only). This gives
61 some information about the FPU initialization performed by the
62 kernel.
63
64 AT_GID The real group ID of the thread.
65
66 AT_HWCAP
67 An architecture and ABI dependent bit-mask whose settings indi‐
68 cate detailed processor capabilities. The contents of the bit
69 mask are hardware dependent (for example, see the kernel source
70 file arch/x86/include/asm/cpufeature.h for details relating to
71 the Intel x86 architecture; the value returned is the first
72 32-bit word of the array described there). A human-readable
73 version of the same information is available via /proc/cpuinfo.
74
75 AT_HWCAP2 (since glibc 2.18)
76 Further machine-dependent hints about processor capabilities.
77
78 AT_ICACHEBSIZE
79 The instruction cache block size.
80
81 AT_L1D_CACHEGEOMETRY
82 Geometry of the L1 data cache, encoded with the cache line size
83 in bytes in the bottom 16 bits and the cache associativity in
84 the next 16 bits. The associativity is such that if N is the
85 16-bit value, the cache is N-way set associative.
86
87 AT_L1D_CACHESIZE
88 The L1 data cache size.
89
90 AT_L1I_CACHEGEOMETRY
91 Geometry of the L1 instruction cache, encoded as for
92 AT_L1D_CACHEGEOMETRY.
93
94 AT_L1I_CACHESIZE
95 The L1 instruction cache size.
96
97 AT_L2_CACHEGEOMETRY
98 Geometry of the L2 cache, encoded as for AT_L1D_CACHEGEOMETRY.
99
100 AT_L2_CACHESIZE
101 The L2 cache size.
102
103 AT_L3_CACHEGEOMETRY
104 Geometry of the L3 cache, encoded as for AT_L1D_CACHEGEOMETRY.
105
106 AT_L3_CACHESIZE
107 The L3 cache size.
108
109 AT_PAGESZ
110 The system page size (the same value returned by
111 sysconf(_SC_PAGESIZE)).
112
113 AT_PHDR
114 The address of the program headers of the executable.
115
116 AT_PHENT
117 The size of program header entry.
118
119 AT_PHNUM
120 The number of program headers.
121
122 AT_PLATFORM
123 A pointer to a string that identifies the hardware platform that
124 the program is running on. The dynamic linker uses this in the
125 interpretation of rpath values.
126
127 AT_RANDOM
128 The address of sixteen bytes containing a random value.
129
130 AT_SECURE
131 Has a nonzero value if this executable should be treated
132 securely. Most commonly, a nonzero value indicates that the
133 process is executing a set-user-ID or set-group-ID binary (so
134 that its real and effective UIDs or GIDs differ from one
135 another), or that it gained capabilities by executing a binary
136 file that has capabilities (see capabilities(7)). Alterna‐
137 tively, a nonzero value may be triggered by a Linux Security
138 Module. When this value is nonzero, the dynamic linker disables
139 the use of certain environment variables (see ld-linux.so(8))
140 and glibc changes other aspects of its behavior. (See also
141 secure_getenv(3).)
142
143 AT_SYSINFO
144 The entry point to the system call function in the vDSO. Not
145 present/needed on all architectures (e.g., absent on x86-64).
146
147 AT_SYSINFO_EHDR
148 The address of a page containing the virtual Dynamic Shared
149 Object (vDSO) that the kernel creates in order to provide fast
150 implementations of certain system calls.
151
152 AT_UCACHEBSIZE
153 The unified cache block size.
154
155 AT_UID The real user ID of the thread.
156
158 On success, getauxval() returns the value corresponding to type. If
159 type is not found, 0 is returned.
160
162 ENOENT (since glibc 2.19)
163 No entry corresponding to type could be found in the auxiliary
164 vector.
165
167 The getauxval() function was added to glibc in version 2.16.
168
170 For an explanation of the terms used in this section, see
171 attributes(7).
172
173 ┌────────────┬───────────────┬─────────┐
174 │Interface │ Attribute │ Value │
175 ├────────────┼───────────────┼─────────┤
176 │getauxval() │ Thread safety │ MT-Safe │
177 └────────────┴───────────────┴─────────┘
179 This function is a nonstandard glibc extension.
180
182 The primary consumer of the information in the auxiliary vector is the
183 dynamic linker, ld-linux.so(8). The auxiliary vector is a convenient
184 and efficient shortcut that allows the kernel to communicate a certain
185 set of standard information that the dynamic linker usually or always
186 needs. In some cases, the same information could be obtained by system
187 calls, but using the auxiliary vector is cheaper.
188
189 The auxiliary vector resides just above the argument list and environ‐
190 ment in the process address space. The auxiliary vector supplied to a
191 program can be viewed by setting the LD_SHOW_AUXV environment variable
192 when running a program:
193
194 $ LD_SHOW_AUXV=1 sleep 1
195
196 The auxiliary vector of any process can (subject to file permissions)
197 be obtained via /proc/[pid]/auxv; see proc(5) for more information.
198
200 Before the addition of the ENOENT error in glibc 2.19, there was no way
201 to unambiguously distinguish the case where type could not be found
202 from the case where the value corresponding to type was zero.
203
205 secure_getenv(3), vdso(7), ld-linux.so(8)
206
208 This page is part of release 5.04 of the Linux man-pages project. A
209 description of the project, information about reporting bugs, and the
210 latest version of this page, can be found at
211 https://www.kernel.org/doc/man-pages/.
212
213
214
215GNU 2019-10-10 GETAUXVAL(3)