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(__powerpc64__) 20 #define SEPARATOR ; 21 #define PPC64_OFFS_SRR0 0 22 #define PPC64_OFFS_CR 272 23 #define PPC64_OFFS_XER 280 24 #define PPC64_OFFS_LR 288 25 #define PPC64_OFFS_CTR 296 26 #define PPC64_OFFS_VRSAVE 304 27 #define PPC64_OFFS_FP 312 28 #define PPC64_OFFS_V 824 29 #ifdef _ARCH_PWR8 30 #define PPC64_HAS_VMX 31 #endif 32 #elif defined(__arm64__) 33 #define SEPARATOR %% 34 #else 35 #define SEPARATOR ; 36 #endif 37 38 #if defined(__powerpc64__) && (!defined(_CALL_ELF) || _CALL_ELF == 1) 39 #define PPC64_OPD1 .section .opd,"aw",@progbits SEPARATOR 40 #define PPC64_OPD2 SEPARATOR \ 41 .p2align 3 SEPARATOR \ 42 .quad .Lfunc_begin0 SEPARATOR \ 43 .quad .TOC.@tocbase SEPARATOR \ 44 .quad 0 SEPARATOR \ 45 .text SEPARATOR \ 46 .Lfunc_begin0: 47 #else 48 #define PPC64_OPD1 49 #define PPC64_OPD2 50 #endif 51 52 #define GLUE2(a, b) a ## b 53 #define GLUE(a, b) GLUE2(a, b) 54 #define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name) 55 56 #if defined(__APPLE__) 57 58 #define SYMBOL_IS_FUNC(name) 59 #define EXPORT_SYMBOL(name) 60 #define HIDDEN_SYMBOL(name) .private_extern name 61 #define NO_EXEC_STACK_DIRECTIVE 62 63 #elif defined(__ELF__) 64 65 #if defined(__arm__) 66 #define SYMBOL_IS_FUNC(name) .type name,%function 67 #else 68 #define SYMBOL_IS_FUNC(name) .type name,@function 69 #endif 70 #define EXPORT_SYMBOL(name) 71 #define HIDDEN_SYMBOL(name) .hidden name 72 73 #if defined(__GNU__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \ 74 defined(__linux__) 75 #define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits 76 #else 77 #define NO_EXEC_STACK_DIRECTIVE 78 #endif 79 80 #elif defined(_WIN32) 81 82 #define SYMBOL_IS_FUNC(name) \ 83 .def name SEPARATOR \ 84 .scl 2 SEPARATOR \ 85 .type 32 SEPARATOR \ 86 .endef 87 #define EXPORT_SYMBOL2(name) \ 88 .section .drectve,"yn" SEPARATOR \ 89 .ascii "-export:", #name, "\0" SEPARATOR \ 90 .text 91 #if defined(_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS) 92 #define EXPORT_SYMBOL(name) 93 #else 94 #define EXPORT_SYMBOL(name) EXPORT_SYMBOL2(name) 95 #endif 96 #define HIDDEN_SYMBOL(name) 97 98 #define NO_EXEC_STACK_DIRECTIVE 99 100 #elif defined(__sparc__) 101 102 #else 103 104 #error Unsupported target 105 106 #endif 107 108 #define DEFINE_LIBUNWIND_FUNCTION(name) \ 109 .globl SYMBOL_NAME(name) SEPARATOR \ 110 EXPORT_SYMBOL(name) SEPARATOR \ 111 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ 112 PPC64_OPD1 \ 113 SYMBOL_NAME(name): \ 114 PPC64_OPD2 115 116 #define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name) \ 117 .globl SYMBOL_NAME(name) SEPARATOR \ 118 HIDDEN_SYMBOL(SYMBOL_NAME(name)) SEPARATOR \ 119 SYMBOL_IS_FUNC(SYMBOL_NAME(name)) SEPARATOR \ 120 PPC64_OPD1 \ 121 SYMBOL_NAME(name): \ 122 PPC64_OPD2 123 124 #if defined(__arm__) 125 #if !defined(__ARM_ARCH) 126 #define __ARM_ARCH 4 127 #endif 128 129 #if defined(__ARM_ARCH_4T__) || __ARM_ARCH >= 5 130 #define ARM_HAS_BX 131 #endif 132 133 #ifdef ARM_HAS_BX 134 #define JMP(r) bx r 135 #else 136 #define JMP(r) mov pc, r 137 #endif 138 #endif /* __arm__ */ 139 140 #endif /* UNWIND_ASSEMBLY_H */ 141