1 /* ===-- assembly.h - libUnwind assembler support macros -------------------=== 2 * 3 * The LLVM Compiler Infrastructure 4 * 5 * This file is dual licensed under the MIT and the University of Illinois Open 6 * Source Licenses. See LICENSE.TXT for details. 7 * 8 * ===----------------------------------------------------------------------=== 9 * 10 * This file defines macros for use in libUnwind assembler source. 11 * This file is not part of the interface of this library. 12 * 13 * ===----------------------------------------------------------------------=== 14 */ 15 16 #ifndef UNWIND_ASSEMBLY_H 17 #define UNWIND_ASSEMBLY_H 18 19 #if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__) 20 #define SEPARATOR @ 21 #elif defined(__arm64__) 22 #define SEPARATOR %% 23 #else 24 #define SEPARATOR ; 25 #endif 26 27 #define GLUE2(a, b) a ## b 28 #define GLUE(a, b) GLUE2(a, b) 29 #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) 30 31 #if defined(__APPLE__) 32 33 #define SYMBOL_IS_FUNC(name) 34 #define HIDDEN_SYMBOL(name) .private_extern name 35 #define NO_EXEC_STACK_DIRECTIVE 36 37 #elif defined(__ELF__) 38 39 #if defined(__arm__) 40 #define SYMBOL_IS_FUNC(name) .type name,%function 41 #else 42 #define SYMBOL_IS_FUNC(name) .type name,@function 43 #endif 44 #define HIDDEN_SYMBOL(name) .hidden name 45 46 #if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \ 47 defined(__linux__) 48 #define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits 49 #else 50 #define NO_EXEC_STACK_DIRECTIVE 51 #endif 52 53 #elif defined(_WIN32) 54 55 #define SYMBOL_IS_FUNC(name) \ 56 .def name SEPARATOR \ 57 .scl 2 SEPARATOR \ 58 .type 32 SEPARATOR \ 59 .endef 60 #define HIDDEN_SYMBOL(name) 61 62 #define NO_EXEC_STACK_DIRECTIVE 63 64 #else 65 66 #error Unsupported target 67 68 #endif 69 70 #define DEFINE_LIBUNWIND_FUNCTION(name) \ 71 .globl SYMBOL_NAME(name) SEPARATOR \ 72 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ 73 SYMBOL_NAME(name): 74 75 #define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name) \ 76 .globl SYMBOL_NAME(name) SEPARATOR \ 77 HIDDEN_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ 78 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ 79 SYMBOL_NAME(name): 80 81 #if defined(__arm__) 82 #if !defined(__ARM_ARCH) 83 #define __ARM_ARCH 4 84 #endif 85 86 #if defined(__ARM_ARCH_4T__) || __ARM_ARCH >= 5 87 #define ARM_HAS_BX 88 #endif 89 90 #ifdef ARM_HAS_BX 91 #define JMP(r) bx r 92 #else 93 #define JMP(r) mov pc, r 94 #endif 95 #endif /* __arm__ */ 96 97 #endif /* UNWIND_ASSEMBLY_H */ 98