1/* SPDX-License-Identifier: BSD-2-Clause */ 2/* 3 * Copyright (c) 2014, STMicroelectronics International N.V. 4 * Copyright (c) 2020, Linaro Limited 5 */ 6 7#if defined(__aarch64__) 8#include <arm64_bti.S> 9#elif defined(__riscv) 10#include <riscv.S> 11#endif 12 13#if defined(__aarch64__) && ((defined(__KERNEL__) && defined(CFG_CORE_BTI)) || \ 14 (!defined(__KERNEL__) && defined(CFG_TA_BTI))) 15#define BTI(...) __VA_ARGS__ 16#else 17#define BTI(...) 18#endif 19 20#if defined(CFG_UNWIND) && defined(__arm__) 21#define UNWIND(...) __VA_ARGS__ 22#else 23#define UNWIND(...) 24#endif 25 26 .macro FUNC name colon section=default align=4 _bti=default 27 .ifc \section\(),default 28 .section .text.\name 29 .else 30 .section \section , "ax" , %progbits 31 .endif 32 .global \name 33 .type \name , %function 34 .balign \align 35 \name \colon 36UNWIND( .fnstart) 37 .ifc \_bti\(),default 38BTI( bti c) 39 .endif 40 .endm 41 42 .macro LOCAL_FUNC name colon section=default align=4 _bti=default 43 .ifc \section\(),default 44 .section .text.\name 45 .else 46 .section \section , "ax" , %progbits 47 .endif 48 .type \name , %function 49 .balign \align 50 \name \colon 51UNWIND( .fnstart) 52 .ifc \_bti\(),default 53BTI( bti c) 54 .endif 55 .endm 56 57 .macro WEAK_FUNC name colon section=default align=4 _bti=default 58 .ifc \section\(),default 59 .section .text.\name 60 .else 61 .section \section , "ax" , %progbits 62 .endif 63 .weak \name 64 .type \name , %function 65 .balign \align 66 \name \colon 67UNWIND( .fnstart) 68 .ifc \_bti\(),default 69BTI( bti c) 70 .endif 71 .endm 72 73 .macro END_FUNC name 74UNWIND( .fnend) 75 .size \name , .-\name 76 .endm 77 78 .macro DATA name colon 79 .global \name 80 .type \name , %object 81 \name \colon 82 .endm 83 84 .macro LOCAL_DATA name colon 85 .type \name , %object 86 \name \colon 87 .endm 88 89 .macro END_DATA name 90 .size \name , .-\name 91 .endm 92