]>
Commit | Line | Data |
---|---|---|
328c17af | 1 | /* AArch64 asm definitions. |
a945c346 | 2 | Copyright (C) 2023-2024 Free Software Foundation, Inc. |
328c17af SN |
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 | #include "auto-target.h" | |
26 | ||
27 | #define L(label) .L ## label | |
28 | ||
29 | /* Marking variant PCS symbol references is important for PLT calls | |
30 | otherwise it is for documenting the PCS in the symbol table. */ | |
31 | #ifdef HAVE_AS_VARIANT_PCS | |
32 | # define variant_pcs(name) .variant_pcs name | |
33 | #else | |
34 | # define variant_pcs(name) | |
35 | #endif | |
36 | ||
37 | /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */ | |
38 | #define FEATURE_1_AND 0xc0000000 | |
39 | #define FEATURE_1_BTI 1 | |
40 | #define FEATURE_1_PAC 2 | |
41 | ||
42 | /* Supported features based on the code generation options. */ | |
43 | #if defined(__ARM_FEATURE_BTI_DEFAULT) | |
44 | # define BTI_FLAG FEATURE_1_BTI | |
45 | # define BTI_C hint 34 | |
46 | #else | |
47 | # define BTI_FLAG 0 | |
48 | # define BTI_C | |
49 | #endif | |
50 | ||
51 | #if __ARM_FEATURE_PAC_DEFAULT & 3 | |
52 | # define PAC_FLAG FEATURE_1_PAC | |
53 | # define PACIASP hint 25; .cfi_window_save | |
54 | # define AUTIASP hint 29; .cfi_window_save | |
55 | #else | |
56 | # define PAC_FLAG 0 | |
57 | # define PACIASP | |
58 | # define AUTIASP | |
59 | #endif | |
60 | ||
61 | /* Add a NT_GNU_PROPERTY_TYPE_0 note. */ | |
62 | #define GNU_PROPERTY(type, value) \ | |
63 | .section .note.gnu.property, "a"; \ | |
64 | .p2align 3; \ | |
65 | .word 4; \ | |
66 | .word 16; \ | |
67 | .word 5; \ | |
68 | .asciz "GNU"; \ | |
69 | .word type; \ | |
70 | .word 4; \ | |
71 | .word value; \ | |
72 | .word 0; \ | |
73 | .previous | |
74 | ||
75 | #if defined(__linux__) || defined(__FreeBSD__) | |
76 | /* Do not require executable stack. */ | |
77 | .section .note.GNU-stack, "", %progbits | |
78 | .previous | |
79 | ||
80 | /* Add GNU property note if built with branch protection. */ | |
81 | # if (BTI_FLAG|PAC_FLAG) != 0 | |
82 | GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG) | |
83 | # endif | |
84 | #endif | |
85 | ||
86 | #define ENTRY_ALIGN(name, align) \ | |
87 | .global name; \ | |
88 | .type name,%function; \ | |
89 | .balign align; \ | |
90 | name: \ | |
91 | .cfi_startproc; \ | |
92 | BTI_C | |
93 | ||
94 | #define ENTRY(name) ENTRY_ALIGN(name, 16) | |
95 | ||
96 | #define END(name) \ | |
97 | .cfi_endproc; \ | |
98 | .size name, .-name |