1GETAUXVAL(3)               Linux Programmer's Manual              GETAUXVAL(3)
2
3
4

NAME

6       getauxval - retrieve a value from the auxiliary vector
7

SYNOPSIS

9       #include <sys/auxv.h>
10
11       unsigned long getauxval(unsigned long type);
12

DESCRIPTION

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

RETURN VALUE

159       On  success,  getauxval()  returns the value corresponding to type.  If
160       type is not found, 0 is returned.
161

ERRORS

163       ENOENT (since glibc 2.19)
164              No entry corresponding to type could be found in  the  auxiliary
165              vector.
166

VERSIONS

168       The getauxval() function was added to glibc in version 2.16.
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       └────────────┴───────────────┴─────────┘

CONFORMING TO

180       This function is a nonstandard glibc extension.
181

NOTES

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

BUGS

201       Before the addition of the ENOENT error in glibc 2.19, there was no way
202       to unambiguously distinguish the case where type  could  not  be  found
203       from the case where the value corresponding to type was zero.
204

SEE ALSO

206       secure_getenv(3), vdso(7), ld-linux.so(8)
207

COLOPHON

209       This  page  is  part of release 5.10 of the Linux man-pages project.  A
210       description of the project, information about reporting bugs,  and  the
211       latest     version     of     this    page,    can    be    found    at
212       https://www.kernel.org/doc/man-pages/.
213
214
215
216GNU                               2020-06-09                      GETAUXVAL(3)
Impressum