Debian Codegraph @

libgcc/config/aarch64/aarch64-asm.h

raw
1 /* AArch64 asm definitions.
2 Copyright (C) 2023-2025 Free Software Foundation, Inc.
3
4 This file is part of GCC.
5
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 3, or (at your
9 option) any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 License for more details.
15
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
24
25 #ifndef AARCH64_ASM_H
26 #define AARCH64_ASM_H
27
28 #include "auto-target.h"
29
30 #define L(label) .L ## label
31
32 /* Marking variant PCS symbol references is important for PLT calls
33 otherwise it is for documenting the PCS in the symbol table. */
34 #ifdef HAVE_AS_VARIANT_PCS
35 # define variant_pcs(name) .variant_pcs name
36 #else
37 # define variant_pcs(name)
38 #endif
39
40 /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */
41 #define FEATURE_1_AND 0xc0000000
42 #define FEATURE_1_BTI 1
43 #define FEATURE_1_PAC 2
44 #define FEATURE_1_GCS 4
45
46 /* Supported features based on the code generation options. */
47 #if defined(__ARM_FEATURE_BTI_DEFAULT)
48 # define BTI_FLAG FEATURE_1_BTI
49 # define BTI_C hint 34
50 #else
51 # define BTI_FLAG 0
52 # define BTI_C
53 #endif
54
55 #if __ARM_FEATURE_PAC_DEFAULT & 3
56 # define PAC_FLAG FEATURE_1_PAC
57 # define PACIASP hint 25; .cfi_negate_ra_state
58 # define AUTIASP hint 29; .cfi_negate_ra_state
59 #else
60 # define PAC_FLAG 0
61 # define PACIASP
62 # define AUTIASP
63 #endif
64
65 #if __ARM_FEATURE_GCS_DEFAULT
66 # define GCS_FLAG FEATURE_1_GCS
67 #else
68 # define GCS_FLAG 0
69 #endif
70
71 #ifdef __ELF__
72 #define HIDDEN(name) .hidden name
73 #define SYMBOL_SIZE(name) .size name, .-name
74 #define SYMBOL_TYPE(name, _type) .type name, _type
75 #else
76 #define HIDDEN(name)
77 #define SYMBOL_SIZE(name)
78 #define SYMBOL_TYPE(name, _type)
79 #endif
80
81 /* Add a NT_GNU_PROPERTY_TYPE_0 note. */
82 #define GNU_PROPERTY(type, value) \
83 .section .note.gnu.property, "a"; \
84 .p2align 3; \
85 .word 4; \
86 .word 16; \
87 .word 5; \
88 .asciz "GNU"; \
89 .word type; \
90 .word 4; \
91 .word value; \
92 .word 0; \
93 .previous
94
95 #if defined(__linux__) || defined(__FreeBSD__)
96 /* Do not require executable stack. */
97 .section .note.GNU-stack, "", %progbits
98 .previous
99
100 /* Add GNU property note if built with branch protection. */
101 # if (BTI_FLAG|PAC_FLAG|GCS_FLAG) != 0
102 GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG|GCS_FLAG)
103 # endif
104 #endif
105
106 #define ENTRY_ALIGN(name, align) \
107 .global name; \
108 SYMBOL_TYPE(name, %function); \
109 .balign align; \
110 name: \
111 .cfi_startproc; \
112 BTI_C
113
114 #define ENTRY(name) ENTRY_ALIGN(name, 16)
115
116 #define END(name) \
117 .cfi_endproc; \
118 SYMBOL_SIZE(name)
119
120 #endif