elf/Makefile: Split and sort PIE tests
[glibc.git] / sysdeps / aarch64 / dl-prop.h
blobdf05c0211df96e4199d5a0f88a7c0dd9ba4a5439
1 /* Support for GNU properties. AArch64 version.
2 Copyright (C) 2018-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #ifndef _DL_PROP_H
20 #define _DL_PROP_H
22 extern void _dl_bti_protect (struct link_map *, int) attribute_hidden;
24 extern void _dl_bti_check (struct link_map *, const char *)
25 attribute_hidden;
27 static inline void __attribute__ ((always_inline))
28 _rtld_main_check (struct link_map *m, const char *program)
30 _dl_bti_check (m, program);
33 static inline void __attribute__ ((always_inline))
34 _dl_open_check (struct link_map *m)
36 _dl_bti_check (m, NULL);
39 static inline void __attribute__ ((always_inline))
40 _dl_process_pt_note (struct link_map *l, int fd, const ElfW(Phdr) *ph)
44 static inline int
45 _dl_process_gnu_property (struct link_map *l, int fd, uint32_t type,
46 uint32_t datasz, void *data)
48 if (!GLRO(dl_aarch64_cpu_features).bti)
49 /* Skip note processing. */
50 return 0;
52 if (type == GNU_PROPERTY_AARCH64_FEATURE_1_AND)
54 /* Stop if the property note is ill-formed. */
55 if (datasz != 4)
56 return 0;
58 unsigned int feature_1 = *(unsigned int *) data;
59 if (feature_1 & GNU_PROPERTY_AARCH64_FEATURE_1_BTI)
60 _dl_bti_protect (l, fd);
62 /* Stop if we processed the property note. */
63 return 0;
65 /* Continue. */
66 return 1;
69 #endif /* _DL_PROP_H */