summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
diff options
context:
space:
mode:
authorKostya Serebryany <kcc@google.com>2013-12-05 07:44:35 +0000
committerKostya Serebryany <kcc@google.com>2013-12-05 07:44:35 +0000
commit14e92c2c62878b574e694bb0f495ec5e3fcb7b8a (patch)
tree175e0a08fc16eea68b985e7e3c7c9bf0dcfae03d /compiler-rt/lib/sanitizer_common/sanitizer_asm.h
parent0504cdafaa69d0ff37b8f840cd913d0ff2e23491 (diff)
downloadbcm5719-llvm-14e92c2c62878b574e694bb0f495ec5e3fcb7b8a.tar.gz
bcm5719-llvm-14e92c2c62878b574e694bb0f495ec5e3fcb7b8a.zip
[sanitizer] support toolchains that don't understand CFI directives
Summary: Support toolchains that don't understand CFI directives. Reviewers: dvyukov Reviewed By: dvyukov CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2336 llvm-svn: 196480
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_asm.h')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_asm.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_asm.h b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
new file mode 100644
index 00000000000..906012a96f1
--- /dev/null
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
@@ -0,0 +1,40 @@
+//===-- sanitizer_asm.h -----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Various support for assemebler.
+//
+//===----------------------------------------------------------------------===//
+
+// Some toolchains do not support .cfi asm directives, so we have to hide
+// them inside macros.
+#if defined(__clang__) || \
+ (defined(__GNUC__) && defined(__GCC_HAVE_DWARF2_CFI_ASM))
+ // GCC defined __GCC_HAVE_DWARF2_CFI_ASM if it supports CFI.
+ // Clang seems to support CFI by default (or not?).
+ // We need two versions of macros: for inline asm and standalone asm files.
+# define CFI_INL_ADJUST_CFA_OFFSET(n) ".cfi_adjust_cfa_offset " #n ";"
+
+# define CFI_STARTPROC .cfi_startproc
+# define CFI_ENDPROC .cfi_endproc
+# define CFI_ADJUST_CFA_OFFSET(n) .cfi_adjust_cfa_offset n
+# define CFI_REL_OFFSET(reg, n) .cfi_rel_offset reg, n
+# define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg
+# define CFI_RESTORE(reg) .cfi_restore reg
+
+#else // No CFI
+# define CFI_INL_ADJUST_CFA_OFFSET(n)
+# define CFI_STARTPROC
+# define CFI_ENDPROC
+# define CFI_ADJUST_CFA_OFFSET(n)
+# define CFI_REL_OFFSET(reg, n)
+# define CFI_DEF_CFA_REGISTER(reg)
+# define CFI_RESTORE(reg)
+#endif
+
+
OpenPOWER on IntegriCloud