]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/getauxval.3
ldd.1, localedef.1, add_key.2, chroot.2, clone.2, fork.2, futex.2, get_mempolicy...
[thirdparty/man-pages.git] / man3 / getauxval.3
CommitLineData
4946106c
MK
1.\" Copyright 2012 Michael Kerrisk <mtk.manpages@gmail.com>
2.\"
93015253 3.\" %%%LICENSE_START(VERBATIM)
4946106c
MK
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.
4b72fb64 23.\" %%%LICENSE_END
4946106c
MK
24.\"
25.\" See also https://lwn.net/Articles/519085/
26.\"
3df541c0 27.TH GETAUXVAL 3 2016-07-17 "GNU" "Linux Programmer's Manual"
4946106c
MK
28.SH NAME
29getauxval \- retrieve a value from the auxiliary vector
30.SH SYNOPSIS
31.nf
32.B #include <sys/auxv.h>
33.sp
34.BI "unsigned long getauxval(unsigned long " type );
35.fi
36.SH DESCRIPTION
37The
38.BR getauxval ()
39function retrieves values from the auxiliary vector,
40a mechanism that the kernel's ELF binary loader
41uses to pass certain information to
42user space when a program is executed.
43
44Each entry in the auxiliary vector consists of a pair of values:
45a type that identifies what this entry represents,
46and a value for that type.
47Given the argument
48.IR type ,
49.BR getauxval ()
50returns the corresponding value.
51
52The value returned for each
53.I type
54is given in the following list.
55Not all
56.I type
57values are present on all architectures.
58.TP
59.BR AT_BASE
60The base address of the program interpreter (usually, the dynamic linker).
61.TP
62.BR AT_BASE_PLATFORM
63A string identifying the real platform; may differ from
fa1d2749 64.BR AT_PLATFORM
4946106c
MK
65(PowerPC only).
66.TP
67.BR AT_CLKTCK
68The frequency with which
69.BR times (2)
70counts.
71This value can also be obtained via
72.IR sysconf(_SC_CLK_TCK) .
73.TP
74.BR AT_DCACHEBSIZE
75The data cache block size.
76.TP
77.BR AT_EGID
78The effective group ID of the thread.
79.TP
80.BR AT_ENTRY
81The entry address of the executable.
82.TP
83.BR AT_EUID
84The effective user ID of the thread.
85.TP
86.BR AT_EXECFD
87File descriptor of program.
88.TP
89.BR AT_EXECFN
90Pathname used to execute program.
91.TP
92.BR AT_FLAGS
93Flags (unused).
94.TP
95.BR AT_FPUCW
fa1d2749 96Used FPU control word (SuperH architecture only).
4946106c
MK
97This gives some information about the FPU initialization
98performed by the kernel.
99.TP
100.BR AT_GID
101The real group ID of the thread.
102.TP
103.BR AT_HWCAP
7e318d44 104An architecture and ABI dependent bit-mask whose settings
4946106c
MK
105indicate detailed processor capabilities.
106The contents of the bit mask are hardware dependent
107(for example, see the kernel source file
108.IR arch/x86/include/asm/cpufeature.h
063bf5a7 109for details relating to the Intel x86 architecture; the value
291415ef 110returned is the first 32-bit word of the array described there).
4946106c
MK
111A human-readable version of the same information is available via
112.IR /proc/cpuinfo .
113.TP
2e380e89
MK
114.BR AT_HWCAP2 " (since glibc 2.18)"
115Further machine-dependent hints about processor capabilities.
116.TP
4946106c
MK
117.BR AT_ICACHEBSIZE
118The instruction cache block size.
119.\" .TP
120.\" .BR AT_IGNORE
121.\" .TP
122.\" .BR AT_IGNOREPPC
123.\" .TP
124.\" .BR AT_NOTELF
125.TP
126.BR AT_PAGESZ
127The system page size (the same value returned by
1e4a9e18 128.IR sysconf(_SC_PAGESIZE) ).
4946106c
MK
129.TP
130.BR AT_PHDR
131The address of the program headers of the executable.
132.TP
133.BR AT_PHENT
134The size of program header entry.
135.TP
136.BR AT_PHNUM
137The number of program headers.
138.TP
139.BR AT_PLATFORM
140A pointer to a string that identifies the hardware platform
141that the program is running on.
142The dynamic linker uses this in the interpretation of
143.IR rpath
144values.
145.TP
146.BR AT_RANDOM
147The address of sixteen bytes containing a random value.
148.TP
149.BR AT_SECURE
150Has a nonzero value if this executable should be treated securely.
151Most commonly, a nonzero value indicates that the process is
422dd47f 152executing a set-user-ID or set-group-ID binary
36f99b92 153(so that its real and effective UIDs or GIDs differ from one another),
422dd47f
MK
154or that it gained capabilities by executing
155a binary file that has capabilities (see
6912d54f
MK
156.BR capabilities (7)).
157Alternatively,
4946106c
MK
158a nonzero value may be triggered by a Linux Security Module.
159When this value is nonzero,
160the dynamic linker disables the use of certain environment variables (see
161.BR ld-linux.so (8))
fa1d2749 162and glibc changes other aspects of its behavior.
4946106c
MK
163(See also
164.BR secure_getenv (3).)
165.TP
166.BR AT_SYSINFO
5d4708c3 167The entry point to the system call function in the vDSO.
4946106c
MK
168Not present/needed on all architectures (e.g., absent on x86-64).
169.TP
170.BR AT_SYSINFO_EHDR
5d4708c3 171The address of a page containing the virtual Dynamic Shared Object (vDSO)
4946106c
MK
172that the kernel creates in order to provide fast implementations of
173certain system calls.
174.TP
175.BR AT_UCACHEBSIZE
176The unified cache block size.
177.TP
178.BR AT_UID
179The real user ID of the thread.
180.SH RETURN VALUE
181On success,
182.BR getauxval ()
183returns the value corresponding to
184.IR type .
185If
186.I type
187is not found, 0 is returned.
188.SH ERRORS
89c1cb59
MK
189.TP
190.BR ENOENT " (since glibc 2.19)"
191.\" commit b9ab448f980e296eac21ac65f53783967cc6037b
192No entry corresponding to
193.IR type
194could be found in the auxiliary vector.
4946106c
MK
195.SH VERSIONS
196The
197.BR getauxval ()
198function was added to glibc in version 2.16.
b727421c 199.SH ATTRIBUTES
8c5731ff
MK
200For an explanation of the terms used in this section, see
201.BR attributes (7).
202.TS
203allbox;
204lb lb lb
205l l l.
206Interface Attribute Value
207T{
b727421c 208.BR getauxval ()
8c5731ff
MK
209T} Thread safety MT-Safe
210.TE
47297adb 211.SH CONFORMING TO
4946106c
MK
212This function is a nonstandard glibc extension.
213.SH NOTES
214The primary consumer of the information in the auxiliary vector
215is the dynamic linker
216.BR ld-linux.so (8).
217The auxiliary vector is a convenient and efficient shortcut
218that allows the kernel to communicate a certain set of standard
219information that the dynamic linker usually or always needs.
220In some cases, the same information could be obtained by system calls,
221but using the auxiliary vector is cheaper.
222
223The auxiliary vector resides just above the argument list and
224environment in the process address space.
225The auxiliary vector supplied to a program can be viewed by setting the
226.B LD_SHOW_AUXV
227environment variable when running a program:
228
229 $ LD_SHOW_AUXV=1 sleep 1
230
231The auxiliary vector of any process can (subject to file permissions)
232be obtained via
233.IR /proc/PID/auxv ;
234see
235.BR proc (5)
236for more information.
89c1cb59
MK
237.SH BUGS
238Before the addition of the
239.B ENOENT
240error in glibc 2.19,
241there was no way to unambiguously distinguish the case where
242.I type
243could not be found from the case where the value corresponding to
244.I type
a03a7435 245was zero.
47297adb 246.SH SEE ALSO
4946106c 247.BR secure_getenv (3),
951ae9c0 248.BR vdso (7),
4946106c 249.BR ld-linux.so (8)