Debian Codegraph @

src/libmpg123/aarch64_defs.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1
2 *
3 * aarch64_defs.h: Support macros for the aarch64 architectural features
4 */
5
6 #ifndef SRC_LIBMPG123_AARCH64_DEFS_H_
7 #define SRC_LIBMPG123_AARCH64_DEFS_H_
8
9 /*
10 * Guard this header so arm assembly files can just include it without the need
11 * to if-def each instance.
12 */
13 #ifdef __aarch64__
14
15 /*
16 * References:
17 * - https://developer.arm.com/documentation/101028/0012/5--Feature-test-macros
18 * - https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst
19 */
20
21 #if defined(__ARM_FEATURE_BTI_DEFAULT) && __ARM_FEATURE_BTI_DEFAULT == 1
22 #define GNU_PROPERTY_AARCH64_BTI 1 /* bit 0 GNU Notes is for BTI support */
23 #else
24 #define GNU_PROPERTY_AARCH64_BTI 0
25 #endif
26
27 #if defined(__ARM_FEATURE_PAC_DEFAULT)
28 #define GNU_PROPERTY_AARCH64_POINTER_AUTH 2 /* bit 1 GNU Notes is for PAC support */
29 #else
30 #define GNU_PROPERTY_AARCH64_POINTER_AUTH 0
31 #endif
32
33 /* Add the BTI support to GNU Notes section */
34 #if defined(__ASSEMBLER__) && defined(__ELF__)
35 #if GNU_PROPERTY_AARCH64_BTI != 0 || GNU_PROPERTY_AARCH64_POINTER_AUTH != 0
36 .pushsection .note.gnu.property, "a"; /* Start a new allocatable section */
37 .balign 8; /* align it on a byte boundry */
38 .long 4; /* size of "GNU\0" */
39 .long 0x10; /* size of descriptor */
40 .long 0x5; /* NT_GNU_PROPERTY_TYPE_0 */
41 .asciz "GNU";
42 .long 0xc0000000; /* GNU_PROPERTY_AARCH64_FEATURE_1_AND */
43 .long 4; /* Four bytes of data */
44 .long (GNU_PROPERTY_AARCH64_BTI|GNU_PROPERTY_AARCH64_POINTER_AUTH); /* BTI or PAC is enabled */
45 .long 0; /* padding for 8 byte alignment */
46 .popsection; /* end the section */
47 #endif /* GNU Notes additions */
48 #endif /* if __ASSEMBLER__ and __ELF__ */
49
50 #endif /* __arch64__ */
51
52 #endif /* SRC_LIBMPG123_AARCH64_DEFS_H_ */