Add mangling macros for Unwind's inline assembly.
This is in preparation for landing an implementation of unw_getcontext
on a system where it's mangled 'unw_getcontext', not '_unw_getcontext'.
git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@197523 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/Unwind/UnwindRegistersRestore.S b/src/Unwind/UnwindRegistersRestore.S
index 5e24e0d..967eeb5 100644
--- a/src/Unwind/UnwindRegistersRestore.S
+++ b/src/Unwind/UnwindRegistersRestore.S
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
+#include "assembly.h"
+
+ .text
#if __i386__
- .text
- .globl __ZN9libunwind13Registers_x866jumptoEv
- .private_extern __ZN9libunwind13Registers_x866jumptoEv
-__ZN9libunwind13Registers_x866jumptoEv:
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv)
#
# void libunwind::Registers_x86::jumpto()
#
@@ -54,10 +54,7 @@
#elif __x86_64__
- .text
- .globl __ZN9libunwind16Registers_x86_646jumptoEv
- .private_extern __ZN9libunwind16Registers_x86_646jumptoEv
-__ZN9libunwind16Registers_x86_646jumptoEv:
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind16Registers_x86_646jumptoEv)
#
# void libunwind::Registers_x86_64::jumpto()
#
@@ -98,10 +95,7 @@
#elif __ppc__
- .text
- .globl __ZN9libunwind13Registers_ppc6jumptoEv
- .private_extern __ZN9libunwind13Registers_ppc6jumptoEv
-__ZN9libunwind13Registers_ppc6jumptoEv:
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind13Registers_ppc6jumptoEv)
;
; void libunwind::Registers_ppc::jumpto()
;
@@ -266,16 +260,13 @@
#elif __arm64__
- .text
- .globl __ZN9libunwind15Registers_arm646jumptoEv
- .private_extern __ZN9libunwind15Registers_arm646jumptoEv
-__ZN9libunwind15Registers_arm646jumptoEv:
;
; void libunwind::Registers_arm64::jumpto()
;
; On entry:
; thread_state pointer is in x0
;
+DEFINE_LIBUNWIND_PRIVATE_FUNCTION(_ZN9libunwind15Registers_arm646jumptoEv)
; skip restore of x0,x1 for now
ldp x2, x3, [x0, #0x010]
ldp x4, x5, [x0, #0x020]
@@ -316,8 +307,4 @@
ldp x0, x1, [x0, #0x000] ; restore x0,x1
ret lr ; jump to pc
-
-
-
#endif
-
diff --git a/src/Unwind/UnwindRegistersSave.S b/src/Unwind/UnwindRegistersSave.S
index 674f813..5f84433 100644
--- a/src/Unwind/UnwindRegistersSave.S
+++ b/src/Unwind/UnwindRegistersSave.S
@@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//
+#include "assembly.h"
.text
@@ -24,8 +25,7 @@
# +-----------------------+ <-- SP
# + +
#
- .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
push %eax
movl 8(%esp), %eax
movl %ebx, 4(%eax)
@@ -60,8 +60,7 @@
# On entry:
# thread_state pointer is in rdi
#
- .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
movq %rax, (%rdi)
movq %rbx, 8(%rdi)
movq %rcx, 16(%rdi)
@@ -96,8 +95,7 @@
; On entry:
; thread_state pointer is in r3
;
- .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
stw r0, 8(r3)
mflr r0
stw r0, 0(r3) ; store lr as ssr0
@@ -240,8 +238,7 @@
; On entry:
; thread_state pointer is in x0
;
- .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
stp x0, x1, [x0, #0x000]
stp x2, x3, [x0, #0x010]
stp x4, x5, [x0, #0x020]
@@ -283,4 +280,3 @@
ret
#endif
-
diff --git a/src/Unwind/assembly.h b/src/Unwind/assembly.h
new file mode 100644
index 0000000..d282de8
--- /dev/null
+++ b/src/Unwind/assembly.h
@@ -0,0 +1,44 @@
+/* ===-- assembly.h - libUnwind assembler support macros -------------------===
+ *
+ * The LLVM Compiler Infrastructure
+ *
+ * This file is dual licensed under the MIT and the University of Illinois Open
+ * Source Licenses. See LICENSE.TXT for details.
+ *
+ * ===----------------------------------------------------------------------===
+ *
+ * This file defines macros for use in libUnwind assembler source.
+ * This file is not part of the interface of this library.
+ *
+ * ===----------------------------------------------------------------------===
+ */
+
+#ifndef UNWIND_ASSEMBLY_H
+#define UNWIND_ASSEMBLY_H
+
+#if defined(__POWERPC__) || defined(__powerpc__) || defined(__ppc__)
+#define SEPARATOR @
+#else
+#define SEPARATOR ;
+#endif
+
+#if defined(__APPLE__)
+#define HIDDEN_DIRECTIVE .private_extern
+#else
+#define HIDDEN_DIRECTIVE .hidden
+#endif
+
+#define GLUE2(a, b) a ## b
+#define GLUE(a, b) GLUE2(a, b)
+#define SYMBOL_NAME(name) GLUE(__USER_LABEL_PREFIX__, name)
+
+#define DEFINE_LIBUNWIND_FUNCTION(name) \
+ .globl SYMBOL_NAME(name) SEPARATOR \
+ SYMBOL_NAME(name):
+
+#define DEFINE_LIBUNWIND_PRIVATE_FUNCTION(name) \
+ .globl SYMBOL_NAME(name) SEPARATOR \
+ HIDDEN_DIRECTIVE SYMBOL_NAME(name) SEPARATOR \
+ SYMBOL_NAME(name):
+
+#endif /* UNWIND_ASSEMBLY_H */