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
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 string identifying the real platform; may differ from AT_PLAT‐
31              FORM (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              Pathname used to execute program.
54
55       AT_FLAGS
56              Flags (unused).
57
58       AT_FPUCW
59              Used  FPU  control  word (SuperH architecture only).  This gives
60              some information about the FPU initialization performed  by  the
61              kernel.
62
63       AT_GID The real group ID of the thread.
64
65       AT_HWCAP
66              An  architecture and ABI dependent bit-mask whose settings indi‐
67              cate detailed processor capabilities.  The contents of  the  bit
68              mask  are hardware dependent (for example, see the kernel source
69              file arch/x86/include/asm/cpufeature.h for details  relating  to
70              the  Intel  x86  architecture;  the  value returned is the first
71              32-bit word of the array  described  there).   A  human-readable
72              version of the same information is available via /proc/cpuinfo.
73
74       AT_HWCAP2 (since glibc 2.18)
75              Further machine-dependent hints about processor capabilities.
76
77       AT_ICACHEBSIZE
78              The instruction cache block size.
79
80       AT_PAGESZ
81              The   system   page   size   (the   same   value   returned   by
82              sysconf(_SC_PAGESIZE)).
83
84       AT_PHDR
85              The address of the program headers of the executable.
86
87       AT_PHENT
88              The size of program header entry.
89
90       AT_PHNUM
91              The number of program headers.
92
93       AT_PLATFORM
94              A pointer to a string that identifies the hardware platform that
95              the  program is running on.  The dynamic linker uses this in the
96              interpretation of rpath values.
97
98       AT_RANDOM
99              The address of sixteen bytes containing a random value.
100
101       AT_SECURE
102              Has a  nonzero  value  if  this  executable  should  be  treated
103              securely.   Most  commonly,  a  nonzero value indicates that the
104              process is executing a set-user-ID or  set-group-ID  binary  (so
105              that  its  real  and  effective  UIDs  or  GIDs  differ from one
106              another), or that it gained capabilities by executing  a  binary
107              file  that  has  capabilities  (see  capabilities(7)).  Alterna‐
108              tively, a nonzero value may be triggered  by  a  Linux  Security
109              Module.  When this value is nonzero, the dynamic linker disables
110              the use of certain environment  variables  (see  ld-linux.so(8))
111              and  glibc  changes  other  aspects  of its behavior.  (See also
112              secure_getenv(3).)
113
114       AT_SYSINFO
115              The entry point to the system call function in  the  vDSO.   Not
116              present/needed on all architectures (e.g., absent on x86-64).
117
118       AT_SYSINFO_EHDR
119              The  address  of  a  page  containing the virtual Dynamic Shared
120              Object (vDSO) that the kernel creates in order to  provide  fast
121              implementations of certain system calls.
122
123       AT_UCACHEBSIZE
124              The unified cache block size.
125
126       AT_UID The real user ID of the thread.
127

RETURN VALUE

129       On  success,  getauxval()  returns the value corresponding to type.  If
130       type is not found, 0 is returned.
131

ERRORS

133       ENOENT (since glibc 2.19)
134              No entry corresponding to type could be found in  the  auxiliary
135              vector.
136

VERSIONS

138       The getauxval() function was added to glibc in version 2.16.
139

ATTRIBUTES

141       For   an   explanation   of   the  terms  used  in  this  section,  see
142       attributes(7).
143
144       ┌────────────┬───────────────┬─────────┐
145Interface   Attribute     Value   
146       ├────────────┼───────────────┼─────────┤
147getauxval() │ Thread safety │ MT-Safe │
148       └────────────┴───────────────┴─────────┘

CONFORMING TO

150       This function is a nonstandard glibc extension.
151

NOTES

153       The primary consumer of the information in the auxiliary vector is  the
154       dynamic  linker  ld-linux.so(8).   The auxiliary vector is a convenient
155       and efficient shortcut that allows the kernel to communicate a  certain
156       set  of  standard information that the dynamic linker usually or always
157       needs.  In some cases, the same information could be obtained by system
158       calls, but using the auxiliary vector is cheaper.
159
160       The  auxiliary vector resides just above the argument list and environ‐
161       ment in the process address space.  The auxiliary vector supplied to  a
162       program  can be viewed by setting the LD_SHOW_AUXV environment variable
163       when running a program:
164
165           $ LD_SHOW_AUXV=1 sleep 1
166
167       The auxiliary vector of any process can (subject to  file  permissions)
168       be obtained via /proc/[pid]/auxv; see proc(5) for more information.
169

BUGS

171       Before the addition of the ENOENT error in glibc 2.19, there was no way
172       to unambiguously distinguish the case where type  could  not  be  found
173       from the case where the value corresponding to type was zero.
174

SEE ALSO

176       secure_getenv(3), vdso(7), ld-linux.so(8)
177

COLOPHON

179       This  page  is  part of release 4.15 of the Linux man-pages project.  A
180       description of the project, information about reporting bugs,  and  the
181       latest     version     of     this    page,    can    be    found    at
182       https://www.kernel.org/doc/man-pages/.
183
184
185
186GNU                               2017-09-15                      GETAUXVAL(3)
Impressum