blob: 6e2e9762eee5e6fc901fa386039d0ac83ac2b05e (
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
|
/* AArch64 definitions for libc main startup.
Copyright (C) 2024 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/>. */
#ifndef _LIBC_START_H
#define _LIBC_START_H
#ifndef SHARED
# include <dl-prop.h>
# ifndef PR_SET_SHADOW_STACK_STATUS
# define PR_GET_SHADOW_STACK_STATUS 71
# define PR_SET_SHADOW_STACK_STATUS 72
# define PR_LOCK_SHADOW_STACK_STATUS 73
# define PR_SHADOW_STACK_ENABLE (1UL << 0)
# define PR_SHADOW_STACK_WRITE (1UL << 1)
# define PR_SHADOW_STACK_PUSH (1UL << 2)
# endif
/* Must be on a top-level stack frame that does not return. */
static inline void __attribute__((always_inline))
aarch64_libc_setup_tls (void)
{
__libc_setup_tls ();
struct link_map *main_map = _dl_get_dl_main_map ();
const ElfW(Phdr) *phdr = GL(dl_phdr);
const ElfW(Phdr) *ph;
for (ph = phdr; ph < phdr + GL(dl_phnum); ph++)
if (ph->p_type == PT_GNU_PROPERTY)
{
_dl_process_pt_gnu_property (main_map, -1, ph);
_rtld_main_check (main_map, _dl_argv[0]);
break;
}
uint64_t s = GL(dl_aarch64_gcs);
if (s != 0)
INLINE_SYSCALL_CALL (prctl, PR_SET_SHADOW_STACK_STATUS, s, 0, 0, 0);
}
# define ARCH_SETUP_IREL() apply_irel ()
# define ARCH_SETUP_TLS() aarch64_libc_setup_tls ()
# define ARCH_APPLY_IREL()
#endif /* ! SHARED */
#endif /* _LIBC_START_H */
|