1 /* AArch64 asm definitions. 2 Copyright (C) 2023-2024 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 #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 #ifdef __ELF__ 62 #define HIDDEN(name) .hidden name 63 #define SYMBOL_SIZE(name) .size name, .-name 64 #define SYMBOL_TYPE(name, _type) .type name, _type 65 #else 66 #define HIDDEN(name) 67 #define SYMBOL_SIZE(name) 68 #define SYMBOL_TYPE(name, _type) 69 #endif 70 71 /* Add a NT_GNU_PROPERTY_TYPE_0 note. */ 72 #define GNU_PROPERTY(type, value) \ 73 .section .note.gnu.property, "a"; \ 74 .p2align 3; \ 75 .word 4; \ 76 .word 16; \ 77 .word 5; \ 78 .asciz "GNU"; \ 79 .word type; \ 80 .word 4; \ 81 .word value; \ 82 .word 0; \ 83 .previous 84 85 #if defined(__linux__) || defined(__FreeBSD__) 86 /* Do not require executable stack. */ 87 .section .note.GNU-stack, "", %progbits 88 .previous 89 90 /* Add GNU property note if built with branch protection. */ 91 # if (BTI_FLAG|PAC_FLAG) != 0 92 GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG) 93 # endif 94 #endif 95 96 #define ENTRY_ALIGN(name, align) \ 97 .global name; \ 98 SYMBOL_TYPE(name, %function); \ 99 .balign align; \ 100 name: \ 101 .cfi_startproc; \ 102 BTI_C 103 104 #define ENTRY(name) ENTRY_ALIGN(name, 16) 105 106 #define END(name) \ 107 .cfi_endproc; \ 108 SYMBOL_SIZE(name) 109