1 /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
2 Contributed by Richard Henderson <rth@redhat.com>.
4 This file is part of the GNU Transactional Memory Library (libitm).
6 Libitm is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 Libitm is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for
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.
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/>. */
28 #define PACIASP hint 25
29 #define AUTIASP hint 29
30 #define PACIBSP hint 27
31 #define AUTIBSP hint 31
33 #if defined(HAVE_AS_CFI_PSEUDO_OP) && defined(__GCC_HAVE_DWARF2_CFI_ASM)
34 # define cfi_window_save .cfi_window_save
35 # define cfi_b_key_frame .cfi_b_key_frame
37 # define cfi_window_save
38 # define cfi_b_key_frame
41 #if __ARM_FEATURE_PAC_DEFAULT & 1
42 # define CFI_PAC_TOGGLE cfi_window_save
44 # define PAC_AND_BTI PACIASP
46 #elif __ARM_FEATURE_PAC_DEFAULT & 2
47 # define CFI_PAC_TOGGLE cfi_window_save
48 # define CFI_PAC_KEY cfi_b_key_frame
49 # define PAC_AND_BTI PACIBSP
52 # define CFI_PAC_TOGGLE
54 # define PAC_AND_BTI BTI_C
60 .global _ITM_beginTransaction
61 .type _ITM_beginTransaction, %function
63 _ITM_beginTransaction:
69 stp x29, x30, [sp, -11*16]!
70 cfi_adjust_cfa_offset(11*16)
71 cfi_rel_offset(x29, 0)
72 cfi_rel_offset(x30, 8)
74 stp x19, x20, [sp, 1*16]
75 stp x21, x22, [sp, 2*16]
76 stp x23, x24, [sp, 3*16]
77 stp x25, x26, [sp, 4*16]
78 stp x27, x28, [sp, 5*16]
79 stp d8, d9, [sp, 6*16]
80 stp d10, d11, [sp, 7*16]
81 stp d12, d13, [sp, 8*16]
82 stp d14, d15, [sp, 9*16]
85 /* Invoke GTM_begin_transaction with the struct we just built. */
87 bl GTM_begin_transaction
89 /* Return; we don't need to restore any of the call-saved regs. */
90 ldp x29, x30, [sp], 11*16
91 cfi_adjust_cfa_offset(-11*16)
98 .size _ITM_beginTransaction, . - _ITM_beginTransaction
103 .type GTM_longjmp, %function
106 /* The first parameter becomes the return value (x0).
107 The third parameter is ignored for now. */
111 ldp x19, x20, [x1, 1*16]
112 ldp x21, x22, [x1, 2*16]
113 ldp x23, x24, [x1, 3*16]
114 ldp x25, x26, [x1, 4*16]
115 ldp x27, x28, [x1, 5*16]
116 ldp d8, d9, [x1, 6*16]
117 ldp d10, d11, [x1, 7*16]
118 ldp d12, d13, [x1, 8*16]
119 ldp d14, d15, [x1, 9*16]
129 .size GTM_longjmp, . - GTM_longjmp
131 /* GNU_PROPERTY_AARCH64_* macros from elf.h for use in asm code. */
132 #define FEATURE_1_AND 0xc0000000
133 #define FEATURE_1_BTI 1
134 #define FEATURE_1_PAC 2
136 /* Supported features based on the code generation options. */
137 #if defined(__ARM_FEATURE_BTI_DEFAULT)
138 # define BTI_FLAG FEATURE_1_BTI
143 #if __ARM_FEATURE_PAC_DEFAULT & 3
144 # define PAC_FLAG FEATURE_1_PAC
149 /* Add a NT_GNU_PROPERTY_TYPE_0 note. */
150 #define GNU_PROPERTY(type, value) \
151 .section .note.gnu.property, "a"; \
162 #if defined(__linux__) || defined(__FreeBSD__)
163 .section .note.GNU-stack, "", %progbits
165 /* Add GNU property note if built with branch protection. */
166 # if (BTI_FLAG|PAC_FLAG) != 0
167 GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG)