blob: 2d4243734ceca7969d2461fe0b0974428ff1148a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
/* Parse the Linux auxiliary vector.
Copyright (C) 1995-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
#include <elf.h>
#include <entry.h>
#include <fpu_control.h>
#include <ldsodefs.h>
#include <link.h>
#include <rseq-internal.h>
typedef ElfW(Addr) dl_parse_auxv_t[AT_MINSIGSTKSZ + 1];
/* Copy the auxiliary vector into AUXV_VALUES and set up GLRO
variables. */
static inline
void _dl_parse_auxv (ElfW(auxv_t) *av, dl_parse_auxv_t auxv_values)
{
auxv_values[AT_ENTRY] = (ElfW(Addr)) ENTRY_POINT;
auxv_values[AT_PAGESZ] = EXEC_PAGESIZE;
auxv_values[AT_FPUCW] = _FPU_DEFAULT;
/* NB: Default to a constant CONSTANT_MINSIGSTKSZ. */
_Static_assert (__builtin_constant_p (CONSTANT_MINSIGSTKSZ),
"CONSTANT_MINSIGSTKSZ is constant");
auxv_values[AT_MINSIGSTKSZ] = CONSTANT_MINSIGSTKSZ;
for (; av->a_type != AT_NULL; av++)
if (av->a_type <= AT_MINSIGSTKSZ)
auxv_values[av->a_type] = av->a_un.a_val;
GLRO(dl_pagesize) = auxv_values[AT_PAGESZ];
__libc_enable_secure = auxv_values[AT_SECURE];
GLRO(dl_platform) = (void *) auxv_values[AT_PLATFORM];
GLRO(dl_hwcap) = auxv_values[AT_HWCAP];
GLRO(dl_hwcap2) = auxv_values[AT_HWCAP2];
GLRO(dl_hwcap3) = auxv_values[AT_HWCAP3];
GLRO(dl_hwcap4) = auxv_values[AT_HWCAP4];
GLRO(dl_clktck) = auxv_values[AT_CLKTCK];
GLRO(dl_fpu_control) = auxv_values[AT_FPUCW];
_dl_random = (void *) auxv_values[AT_RANDOM];
GLRO(dl_minsigstacksize) = auxv_values[AT_MINSIGSTKSZ];
GLRO(dl_sysinfo_dso) = (void *) auxv_values[AT_SYSINFO_EHDR];
#ifdef NEED_DL_SYSINFO
if (GLRO(dl_sysinfo_dso) != NULL)
GLRO(dl_sysinfo) = auxv_values[AT_SYSINFO];
#endif
/* Get the rseq feature size, with a minimum of RSEQ_AREA_SIZE_INITIAL_USED
(20) for kernels that don't have AT_RSEQ_FEATURE_SIZE. Limit the feature
size to RSEQ_AREA_SIZE_MAX_USED (28) which fits the rseq area in 'struct
pthread' and represents the maximum feature size of currently released
kernels. Since no kernels currently cross the 32 bytes of the original
ABI, the semantics of a feature size of 32 or more are still undetermined.
*/
_rseq_size = MIN (MAX (auxv_values[AT_RSEQ_FEATURE_SIZE],
RSEQ_AREA_SIZE_INITIAL_USED),
RSEQ_AREA_SIZE_MAX_USED);
_rseq_align = MAX (auxv_values[AT_RSEQ_ALIGN], RSEQ_MIN_ALIGN);
DL_PLATFORM_AUXV
}
|