1getauxval(3)               Library Functions Manual               getauxval(3)
2
3
4

NAME

6       getauxval - retrieve a value from the auxiliary vector
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <sys/auxv.h>
13
14       unsigned long getauxval(unsigned long type);
15

DESCRIPTION

17       The  getauxval() function retrieves values from the auxiliary vector, a
18       mechanism that the kernel's ELF binary loader uses to pass certain  in‐
19       formation to user space when a program is executed.
20
21       Each entry in the auxiliary vector consists of a pair of values: a type
22       that identifies what this entry represents, and a value for that  type.
23       Given the argument type, getauxval() returns the corresponding value.
24
25       The  value  returned for each type is given in the following list.  Not
26       all type values are present on all architectures.
27
28       AT_BASE
29              The base address of the program interpreter  (usually,  the  dy‐
30              namic linker).
31
32       AT_BASE_PLATFORM
33              A pointer to a string (PowerPC and MIPS only).  On PowerPC, this
34              identifies the real platform; may differ from  AT_PLATFORM.   On
35              MIPS, this identifies the ISA level (since Linux 5.7).
36
37       AT_CLKTCK
38              The  frequency  with which times(2) counts.  This value can also
39              be obtained via sysconf(_SC_CLK_TCK).
40
41       AT_DCACHEBSIZE
42              The data cache block size.
43
44       AT_EGID
45              The effective group ID of the thread.
46
47       AT_ENTRY
48              The entry address of the executable.
49
50       AT_EUID
51              The effective user ID of the thread.
52
53       AT_EXECFD
54              File descriptor of program.
55
56       AT_EXECFN
57              A pointer to a string containing the pathname  used  to  execute
58              the program.
59
60       AT_FLAGS
61              Flags (unused).
62
63       AT_FPUCW
64              Used  FPU  control  word (SuperH architecture only).  This gives
65              some information about the FPU initialization performed  by  the
66              kernel.
67
68       AT_GID The real group ID of the thread.
69
70       AT_HWCAP
71              An  architecture and ABI dependent bit-mask whose settings indi‐
72              cate detailed processor capabilities.  The contents of  the  bit
73              mask  are hardware dependent (for example, see the kernel source
74              file arch/x86/include/asm/cpufeature.h for details  relating  to
75              the  Intel  x86  architecture;  the  value returned is the first
76              32-bit word of the array  described  there).   A  human-readable
77              version of the same information is available via /proc/cpuinfo.
78
79       AT_HWCAP2 (since glibc 2.18)
80              Further machine-dependent hints about processor capabilities.
81
82       AT_ICACHEBSIZE
83              The instruction cache block size.
84
85       AT_L1D_CACHEGEOMETRY
86              Geometry  of the L1 data cache, encoded with the cache line size
87              in bytes in the bottom 16 bits and the  cache  associativity  in
88              the  next  16  bits.  The associativity is such that if N is the
89              16-bit value, the cache is N-way set associative.
90
91       AT_L1D_CACHESIZE
92              The L1 data cache size.
93
94       AT_L1I_CACHEGEOMETRY
95              Geometry  of  the  L1  instruction   cache,   encoded   as   for
96              AT_L1D_CACHEGEOMETRY.
97
98       AT_L1I_CACHESIZE
99              The L1 instruction cache size.
100
101       AT_L2_CACHEGEOMETRY
102              Geometry of the L2 cache, encoded as for AT_L1D_CACHEGEOMETRY.
103
104       AT_L2_CACHESIZE
105              The L2 cache size.
106
107       AT_L3_CACHEGEOMETRY
108              Geometry of the L3 cache, encoded as for AT_L1D_CACHEGEOMETRY.
109
110       AT_L3_CACHESIZE
111              The L3 cache size.
112
113       AT_PAGESZ
114              The system page size (the same value returned by sysconf(_SC_PA‐
115              GESIZE)).
116
117       AT_PHDR
118              The address of the program headers of the executable.
119
120       AT_PHENT
121              The size of program header entry.
122
123       AT_PHNUM
124              The number of program headers.
125
126       AT_PLATFORM
127              A pointer to a string that identifies the hardware platform that
128              the  program is running on.  The dynamic linker uses this in the
129              interpretation of rpath values.
130
131       AT_RANDOM
132              The address of sixteen bytes containing a random value.
133
134       AT_SECURE
135              Has a nonzero value if this executable  should  be  treated  se‐
136              curely.   Most  commonly,  a  nonzero  value  indicates that the
137              process is executing a set-user-ID or  set-group-ID  binary  (so
138              that  its  real  and  effective UIDs or GIDs differ from one an‐
139              other), or that it gained capabilities  by  executing  a  binary
140              file  that  has  capabilities  (see  capabilities(7)).  Alterna‐
141              tively, a nonzero value may be triggered  by  a  Linux  Security
142              Module.  When this value is nonzero, the dynamic linker disables
143              the use of certain environment  variables  (see  ld-linux.so(8))
144              and  glibc changes other aspects of its behavior.  (See also se‐
145              cure_getenv(3).)
146
147       AT_SYSINFO
148              The entry point to the system call function in  the  vDSO.   Not
149              present/needed on all architectures (e.g., absent on x86-64).
150
151       AT_SYSINFO_EHDR
152              The  address of a page containing the virtual Dynamic Shared Ob‐
153              ject (vDSO) that the kernel creates in order to provide fast im‐
154              plementations of certain system calls.
155
156       AT_UCACHEBSIZE
157              The unified cache block size.
158
159       AT_UID The real user ID of the thread.
160

RETURN VALUE

162       On  success,  getauxval()  returns the value corresponding to type.  If
163       type is not found, 0 is returned.
164

ERRORS

166       ENOENT (since glibc 2.19)
167              No entry corresponding to type could be found in  the  auxiliary
168              vector.
169

ATTRIBUTES

171       For  an  explanation  of  the  terms  used  in  this  section,  see at‐
172       tributes(7).
173
174       ┌────────────────────────────────────────────┬───────────────┬─────────┐
175Interface                                   Attribute     Value   
176       ├────────────────────────────────────────────┼───────────────┼─────────┤
177getauxval()                                 │ Thread safety │ MT-Safe │
178       └────────────────────────────────────────────┴───────────────┴─────────┘
179

STANDARDS

181       GNU.
182

HISTORY

184       glibc 2.16.
185

NOTES

187       The primary consumer of the information in the auxiliary vector is  the
188       dynamic  linker,  ld-linux.so(8).  The auxiliary vector is a convenient
189       and efficient shortcut that allows the kernel to communicate a  certain
190       set  of  standard information that the dynamic linker usually or always
191       needs.  In some cases, the same information could be obtained by system
192       calls, but using the auxiliary vector is cheaper.
193
194       The   auxiliary  vector  resides  just  above  the  argument  list  and
195       environment  in  the  process  address  space.   The  auxiliary  vector
196       supplied  to  a  program  can  be  viewed  by  setting the LD_SHOW_AUXV
197       environment variable when running a program:
198
199           $ LD_SHOW_AUXV=1 sleep 1
200
201       The auxiliary vector of any process can (subject to  file  permissions)
202       be obtained via /proc/pid/auxv; see proc(5) for more information.
203

BUGS

205       Before the addition of the ENOENT error in glibc 2.19, there was no way
206       to unambiguously distinguish the case where type  could  not  be  found
207       from the case where the value corresponding to type was zero.
208

SEE ALSO

210       execve(2), secure_getenv(3), vdso(7), ld-linux.so(8)
211
212
213
214Linux man-pages 6.05              2023-07-20                      getauxval(3)
Impressum