summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKuba Mracek <mracek@apple.com>2017-11-29 19:27:25 +0000
committerKuba Mracek <mracek@apple.com>2017-11-29 19:27:25 +0000
commit0a7288064854a3ff716d928a0ab72fdd2bbddb72 (patch)
tree81d7453cf3a8ab393d237a36826baf7546699664
parent17c071e3dcbb1ee6d107a12096ec26750fb816c0 (diff)
[sanitizer] Refactor how assembly files are handled
This renames ASM_TSAN_SYMBOL and ASM_TSAN_SYMBOL_INTERCEPTOR to just ASM_SYMBOL and ASM_SYMBOL_INTERCEPTOR, because they can be useful in more places than just TSan. Also introduce a CMake function to add ASM sources to a target. Differential Revision: https://reviews.llvm.org/D40143 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@319339 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--cmake/Modules/AddCompilerRT.cmake11
-rw-r--r--lib/sanitizer_common/sanitizer_asm.h8
-rw-r--r--lib/tsan/CMakeLists.txt31
-rw-r--r--lib/tsan/rtl/tsan_rtl_aarch64.S50
-rw-r--r--lib/tsan/rtl/tsan_rtl_amd64.S74
-rw-r--r--lib/xray/CMakeLists.txt8
-rw-r--r--lib/xray/xray_trampoline_x86_64.S32
7 files changed, 100 insertions, 114 deletions
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index c50afbcab..8f9857923 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -93,6 +93,17 @@ function(add_compiler_rt_component name)
add_dependencies(compiler-rt ${name})
endfunction()
+function(add_asm_sources output)
+ set(${output} ${ARGN} PARENT_SCOPE)
+ # Xcode will try to compile asm files as C ('clang -x c'), and that will fail.
+ if (${CMAKE_GENERATOR} STREQUAL "Xcode")
+ enable_language(ASM)
+ else()
+ # Pass ASM file directly to the C++ compiler.
+ set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C)
+ endif()
+endfunction()
+
macro(set_output_name output name arch)
if(ANDROID AND ${arch} STREQUAL "i386")
set(${output} "${name}-i686${COMPILER_RT_OS_SUFFIX}")
diff --git a/lib/sanitizer_common/sanitizer_asm.h b/lib/sanitizer_common/sanitizer_asm.h
index 47c2b12a2..76a0bf714 100644
--- a/lib/sanitizer_common/sanitizer_asm.h
+++ b/lib/sanitizer_common/sanitizer_asm.h
@@ -47,12 +47,12 @@
# define ASM_HIDDEN(symbol) .hidden symbol
# define ASM_TYPE_FUNCTION(symbol) .type symbol, @function
# define ASM_SIZE(symbol) .size symbol, .-symbol
-# define ASM_TSAN_SYMBOL(symbol) symbol
-# define ASM_TSAN_SYMBOL_INTERCEPTOR(symbol) symbol
+# define ASM_SYMBOL(symbol) symbol
+# define ASM_SYMBOL_INTERCEPTOR(symbol) symbol
#else
# define ASM_HIDDEN(symbol)
# define ASM_TYPE_FUNCTION(symbol)
# define ASM_SIZE(symbol)
-# define ASM_TSAN_SYMBOL(symbol) _##symbol
-# define ASM_TSAN_SYMBOL_INTERCEPTOR(symbol) _wrap_##symbol
+# define ASM_SYMBOL(symbol) _##symbol
+# define ASM_SYMBOL_INTERCEPTOR(symbol) _wrap_##symbol
#endif
diff --git a/lib/tsan/CMakeLists.txt b/lib/tsan/CMakeLists.txt
index f7a5d70a3..145cd623d 100644
--- a/lib/tsan/CMakeLists.txt
+++ b/lib/tsan/CMakeLists.txt
@@ -100,14 +100,7 @@ set(TSAN_RUNTIME_LIBRARIES)
add_compiler_rt_component(tsan)
if(APPLE)
- set(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S rtl/tsan_rtl_aarch64.S)
- # Xcode will try to compile this file as C ('clang -x c'), and that will fail.
- if (${CMAKE_GENERATOR} STREQUAL "Xcode")
- enable_language(ASM)
- else()
- # Pass ASM file directly to the C++ compiler.
- set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES LANGUAGE C)
- endif()
+ add_asm_sources(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S rtl/tsan_rtl_aarch64.S)
set(TSAN_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS})
@@ -145,10 +138,7 @@ if(APPLE)
else()
foreach(arch ${TSAN_SUPPORTED_ARCH})
if(arch STREQUAL "x86_64")
- set(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S)
- # Pass ASM file directly to the C++ compiler.
- set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES
- LANGUAGE C)
+ add_asm_sources(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S)
# Sanity check for Go runtime.
set(BUILDGO_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/go/buildgo.sh)
add_custom_target(GotsanRuntimeCheck
@@ -159,20 +149,11 @@ else()
COMMENT "Checking TSan Go runtime..."
VERBATIM)
elseif(arch STREQUAL "aarch64")
- set(TSAN_ASM_SOURCES rtl/tsan_rtl_aarch64.S)
- # Pass ASM file directly to the C++ compiler.
- set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES
- LANGUAGE C)
- elseif(arch MATCHES "powerpc64|powerpc64le")
- set(TSAN_ASM_SOURCES rtl/tsan_rtl_ppc64.S)
- # Pass ASM file directly to the C++ compiler.
- set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES
- LANGUAGE C)
+ add_asm_sources(TSAN_ASM_SOURCES rtl/tsan_rtl_aarch64.S)
+ elseif(arch MATCHES "powerpc64|powerpc64le")
+ add_asm_sources(TSAN_ASM_SOURCES rtl/tsan_rtl_ppc64.S)
elseif(arch MATCHES "mips64|mips64le")
- set(TSAN_ASM_SOURCES rtl/tsan_rtl_mips64.S)
- # Pass ASM file directly to the C++ compiler.
- set_source_files_properties(${TSAN_ASM_SOURCES} PROPERTIES
- LANGUAGE C)
+ add_asm_sources(TSAN_ASM_SOURCES rtl/tsan_rtl_mips64.S)
else()
set(TSAN_ASM_SOURCES)
endif()
diff --git a/lib/tsan/rtl/tsan_rtl_aarch64.S b/lib/tsan/rtl/tsan_rtl_aarch64.S
index 61171d635..844c2e23d 100644
--- a/lib/tsan/rtl/tsan_rtl_aarch64.S
+++ b/lib/tsan/rtl/tsan_rtl_aarch64.S
@@ -6,7 +6,7 @@
#if !defined(__APPLE__)
.section .bss
.type __tsan_pointer_chk_guard, %object
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(__tsan_pointer_chk_guard))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__tsan_pointer_chk_guard))
__tsan_pointer_chk_guard:
.zero 8
#endif
@@ -51,7 +51,7 @@ _sigsetjmp$non_lazy_ptr:
// original ones.
ASM_HIDDEN(_Z18InitializeGuardPtrv)
.global _Z18InitializeGuardPtrv
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(_Z18InitializeGuardPtrv))
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_Z18InitializeGuardPtrv))
_Z18InitializeGuardPtrv:
CFI_STARTPROC
// Allocates a jmp_buf for the setjmp call.
@@ -88,14 +88,14 @@ _Z18InitializeGuardPtrv:
CFI_DEF_CFA (31, 0)
ret
CFI_ENDPROC
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(_Z18InitializeGuardPtrv))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_Z18InitializeGuardPtrv))
#endif
ASM_HIDDEN(__tsan_setjmp)
.comm _ZN14__interception11real_setjmpE,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
+ASM_SYMBOL_INTERCEPTOR(setjmp):
CFI_STARTPROC
// save env parameters for function call
@@ -125,7 +125,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp):
#endif
// call tsan interceptor
- bl ASM_TSAN_SYMBOL(__tsan_setjmp)
+ bl ASM_SYMBOL(__tsan_setjmp)
// restore env parameter
mov x0, x19
@@ -148,12 +148,12 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp):
br x1
CFI_ENDPROC
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
.comm _ZN14__interception12real__setjmpE,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
+ASM_SYMBOL_INTERCEPTOR(_setjmp):
CFI_STARTPROC
// save env parameters for function call
@@ -183,7 +183,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp):
#endif
// call tsan interceptor
- bl ASM_TSAN_SYMBOL(__tsan_setjmp)
+ bl ASM_SYMBOL(__tsan_setjmp)
// Restore jmp_buf parameter
mov x0, x19
@@ -206,12 +206,12 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp):
br x1
CFI_ENDPROC
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_setjmp))
.comm _ZN14__interception14real_sigsetjmpE,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(sigsetjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
+ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
CFI_STARTPROC
// save env parameters for function call
@@ -243,7 +243,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp):
#endif
// call tsan interceptor
- bl ASM_TSAN_SYMBOL(__tsan_setjmp)
+ bl ASM_SYMBOL(__tsan_setjmp)
// restore env parameter
mov w1, w20
@@ -268,13 +268,13 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp):
#endif
br x2
CFI_ENDPROC
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
#if !defined(__APPLE__)
.comm _ZN14__interception16real___sigsetjmpE,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
+ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
CFI_STARTPROC
// save env parameters for function call
@@ -303,7 +303,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp):
#endif
// call tsan interceptor
- bl ASM_TSAN_SYMBOL(__tsan_setjmp)
+ bl ASM_SYMBOL(__tsan_setjmp)
mov w1, w20
mov x0, x19
@@ -321,12 +321,12 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp):
ldr x2, [x2, #:got_lo12:_ZN14__interception16real___sigsetjmpE]
ldr x2, [x2]
#else
- adrp x2, ASM_TSAN_SYMBOL(__sigsetjmp)@page
- add x2, x2, ASM_TSAN_SYMBOL(__sigsetjmp)@pageoff
+ adrp x2, ASM_SYMBOL(__sigsetjmp)@page
+ add x2, x2, ASM_SYMBOL(__sigsetjmp)@pageoff
#endif
br x2
CFI_ENDPROC
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
#endif
#if defined(__linux__)
diff --git a/lib/tsan/rtl/tsan_rtl_amd64.S b/lib/tsan/rtl/tsan_rtl_amd64.S
index a3531b50b..8af61bf0e 100644
--- a/lib/tsan/rtl/tsan_rtl_amd64.S
+++ b/lib/tsan/rtl/tsan_rtl_amd64.S
@@ -10,8 +10,8 @@
#endif
ASM_HIDDEN(__tsan_trace_switch)
-.globl ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk)
-ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk):
+.globl ASM_SYMBOL(__tsan_trace_switch_thunk)
+ASM_SYMBOL(__tsan_trace_switch_thunk):
CFI_STARTPROC
# Save scratch registers.
push %rax
@@ -50,7 +50,7 @@ ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk):
shr $4, %rsp # clear 4 lsb, align to 16
shl $4, %rsp
- call ASM_TSAN_SYMBOL(__tsan_trace_switch)
+ call ASM_SYMBOL(__tsan_trace_switch)
# Unalign stack frame back.
mov %rbx, %rsp # restore the original rsp
@@ -90,8 +90,8 @@ ASM_TSAN_SYMBOL(__tsan_trace_switch_thunk):
CFI_ENDPROC
ASM_HIDDEN(__tsan_report_race)
-.globl ASM_TSAN_SYMBOL(__tsan_report_race_thunk)
-ASM_TSAN_SYMBOL(__tsan_report_race_thunk):
+.globl ASM_SYMBOL(__tsan_report_race_thunk)
+ASM_SYMBOL(__tsan_report_race_thunk):
CFI_STARTPROC
# Save scratch registers.
push %rax
@@ -130,7 +130,7 @@ ASM_TSAN_SYMBOL(__tsan_report_race_thunk):
shr $4, %rsp # clear 4 lsb, align to 16
shl $4, %rsp
- call ASM_TSAN_SYMBOL(__tsan_report_race)
+ call ASM_SYMBOL(__tsan_report_race)
# Unalign stack frame back.
mov %rbx, %rsp # restore the original rsp
@@ -176,13 +176,13 @@ ASM_HIDDEN(__tsan_setjmp)
.comm _ZN14__interception11real_setjmpE,8,8
#endif
#if defined(__NetBSD__)
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(__setjmp14)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(__setjmp14))
-ASM_TSAN_SYMBOL_INTERCEPTOR(__setjmp14):
+.globl ASM_SYMBOL_INTERCEPTOR(__setjmp14)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__setjmp14))
+ASM_SYMBOL_INTERCEPTOR(__setjmp14):
#else
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(setjmp))
+ASM_SYMBOL_INTERCEPTOR(setjmp):
#endif
CFI_STARTPROC
// save env parameter
@@ -205,7 +205,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp):
# error "Unknown platform"
#endif
// call tsan interceptor
- call ASM_TSAN_SYMBOL(__tsan_setjmp)
+ call ASM_SYMBOL(__tsan_setjmp)
// restore env parameter
pop %rdi
CFI_ADJUST_CFA_OFFSET(-8)
@@ -219,19 +219,19 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp):
movq _ZN14__interception11real_setjmpE@GOTPCREL(%rip), %rdx
jmp *(%rdx)
#else
- jmp ASM_TSAN_SYMBOL(setjmp)
+ jmp ASM_SYMBOL(setjmp)
#endif
CFI_ENDPROC
#if defined(__NetBSD__)
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(__setjmp14))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__setjmp14))
#else
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(setjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(setjmp))
#endif
.comm _ZN14__interception12real__setjmpE,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(_setjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(_setjmp))
+ASM_SYMBOL_INTERCEPTOR(_setjmp):
CFI_STARTPROC
// save env parameter
push %rdi
@@ -253,7 +253,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp):
# error "Unknown platform"
#endif
// call tsan interceptor
- call ASM_TSAN_SYMBOL(__tsan_setjmp)
+ call ASM_SYMBOL(__tsan_setjmp)
// restore env parameter
pop %rdi
CFI_ADJUST_CFA_OFFSET(-8)
@@ -264,21 +264,21 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp):
movq _ZN14__interception12real__setjmpE@GOTPCREL(%rip), %rdx
jmp *(%rdx)
#else
- jmp ASM_TSAN_SYMBOL(_setjmp)
+ jmp ASM_SYMBOL(_setjmp)
#endif
CFI_ENDPROC
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(_setjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(_setjmp))
#if defined(__NetBSD__)
.comm _ZN14__interception18real___sigsetjmp14E,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp14)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp14))
-ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp14):
+.globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14))
+ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14):
#else
.comm _ZN14__interception14real_sigsetjmpE,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(sigsetjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
+ASM_SYMBOL_INTERCEPTOR(sigsetjmp):
#endif
CFI_STARTPROC
// save env parameter
@@ -308,7 +308,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp):
# error "Unknown platform"
#endif
// call tsan interceptor
- call ASM_TSAN_SYMBOL(__tsan_setjmp)
+ call ASM_SYMBOL(__tsan_setjmp)
// unalign stack frame
add $8, %rsp
CFI_ADJUST_CFA_OFFSET(-8)
@@ -329,20 +329,20 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp):
movq _ZN14__interception14real_sigsetjmpE@GOTPCREL(%rip), %rdx
jmp *(%rdx)
#else
- jmp ASM_TSAN_SYMBOL(sigsetjmp)
+ jmp ASM_SYMBOL(sigsetjmp)
#endif
CFI_ENDPROC
#if defined(__NetBSD__)
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp14))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp14))
#else
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(sigsetjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(sigsetjmp))
#endif
#if !defined(__APPLE__) && !defined(__NetBSD__)
.comm _ZN14__interception16real___sigsetjmpE,8,8
-.globl ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp)
-ASM_TYPE_FUNCTION(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp))
-ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp):
+.globl ASM_SYMBOL_INTERCEPTOR(__sigsetjmp)
+ASM_TYPE_FUNCTION(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
+ASM_SYMBOL_INTERCEPTOR(__sigsetjmp):
CFI_STARTPROC
// save env parameter
push %rdi
@@ -366,7 +366,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp):
rol $0x11, %rsi
#endif
// call tsan interceptor
- call ASM_TSAN_SYMBOL(__tsan_setjmp)
+ call ASM_SYMBOL(__tsan_setjmp)
// unalign stack frame
add $8, %rsp
CFI_ADJUST_CFA_OFFSET(-8)
@@ -383,7 +383,7 @@ ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp):
movq _ZN14__interception16real___sigsetjmpE@GOTPCREL(%rip), %rdx
jmp *(%rdx)
CFI_ENDPROC
-ASM_SIZE(ASM_TSAN_SYMBOL_INTERCEPTOR(__sigsetjmp))
+ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
#endif // !defined(__APPLE__) && !defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__linux__)
diff --git a/lib/xray/CMakeLists.txt b/lib/xray/CMakeLists.txt
index dcf0efc72..fd00f3a40 100644
--- a/lib/xray/CMakeLists.txt
+++ b/lib/xray/CMakeLists.txt
@@ -66,13 +66,7 @@ set(XRAY_COMMON_RUNTIME_OBJECT_LIBS
if (APPLE)
set(XRAY_LINK_LIBS ${SANITIZER_COMMON_LINK_LIBS})
- set(XRAY_ASM_SOURCES xray_trampoline_x86_64.S)
-
- if (${CMAKE_GENERATOR} STREQUAL "Xcode")
- enable_language(ASM)
- else()
- set_source_files_properties(${XRAY_ASM_SOURCES} PROPERTIES LANGUAGE C)
- endif()
+ add_asm_sources(XRAY_ASM_SOURCES xray_trampoline_x86_64.S)
add_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
add_weak_symbols("xray" WEAK_SYMBOL_LINK_FLAGS)
diff --git a/lib/xray/xray_trampoline_x86_64.S b/lib/xray/xray_trampoline_x86_64.S
index 0ae85c78a..350afd926 100644
--- a/lib/xray/xray_trampoline_x86_64.S
+++ b/lib/xray/xray_trampoline_x86_64.S
@@ -87,16 +87,16 @@
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_FunctionEntry)
+ .globl ASM_SYMBOL(__xray_FunctionEntry)
.align 16, 0x90
ASM_TYPE_FUNCTION(__xray_FunctionEntry)
-ASM_TSAN_SYMBOL(__xray_FunctionEntry):
+ASM_SYMBOL(__xray_FunctionEntry):
CFI_STARTPROC
SAVE_REGISTERS
// This load has to be atomic, it's concurrent with __xray_patch().
// On x86/amd64, a simple (type-aligned) MOV instruction is enough.
- movq ASM_TSAN_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
+ movq ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
testq %rax, %rax
je .Ltmp0
@@ -113,10 +113,10 @@ ASM_TSAN_SYMBOL(__xray_FunctionEntry):
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_FunctionExit)
+ .globl ASM_SYMBOL(__xray_FunctionExit)
.align 16, 0x90
ASM_TYPE_FUNCTION(__xray_FunctionExit)
-ASM_TSAN_SYMBOL(__xray_FunctionExit):
+ASM_SYMBOL(__xray_FunctionExit):
CFI_STARTPROC
// Save the important registers first. Since we're assuming that this
// function is only jumped into, we only preserve the registers for
@@ -128,7 +128,7 @@ ASM_TSAN_SYMBOL(__xray_FunctionExit):
movupd %xmm1, 16(%rsp)
movq %rax, 8(%rsp)
movq %rdx, 0(%rsp)
- movq ASM_TSAN_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
+ movq ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
testq %rax,%rax
je .Ltmp2
@@ -151,14 +151,14 @@ ASM_TSAN_SYMBOL(__xray_FunctionExit):
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_FunctionTailExit)
+ .globl ASM_SYMBOL(__xray_FunctionTailExit)
.align 16, 0x90
ASM_TYPE_FUNCTION(__xray_FunctionTailExit)
-ASM_TSAN_SYMBOL(__xray_FunctionTailExit):
+ASM_SYMBOL(__xray_FunctionTailExit):
CFI_STARTPROC
SAVE_REGISTERS
- movq ASM_TSAN_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
+ movq ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
testq %rax,%rax
je .Ltmp4
@@ -175,20 +175,20 @@ ASM_TSAN_SYMBOL(__xray_FunctionTailExit):
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_ArgLoggerEntry)
+ .globl ASM_SYMBOL(__xray_ArgLoggerEntry)
.align 16, 0x90
ASM_TYPE_FUNCTION(__xray_ArgLoggerEntry)
-ASM_TSAN_SYMBOL(__xray_ArgLoggerEntry):
+ASM_SYMBOL(__xray_ArgLoggerEntry):
CFI_STARTPROC
SAVE_REGISTERS
// Again, these function pointer loads must be atomic; MOV is fine.
- movq ASM_TSAN_SYMBOL(_ZN6__xray13XRayArgLoggerE)(%rip), %rax
+ movq ASM_SYMBOL(_ZN6__xray13XRayArgLoggerE)(%rip), %rax
testq %rax, %rax
jne .Larg1entryLog
// If [arg1 logging handler] not set, defer to no-arg logging.
- movq ASM_TSAN_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
+ movq ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
testq %rax, %rax
je .Larg1entryFail
@@ -212,17 +212,17 @@ ASM_TSAN_SYMBOL(__xray_ArgLoggerEntry):
//===----------------------------------------------------------------------===//
- .global ASM_TSAN_SYMBOL(__xray_CustomEvent)
+ .global ASM_SYMBOL(__xray_CustomEvent)
.align 16, 0x90
ASM_TYPE_FUNCTION(__xray_CustomEvent)
-ASM_TSAN_SYMBOL(__xray_CustomEvent):
+ASM_SYMBOL(__xray_CustomEvent):
CFI_STARTPROC
SAVE_REGISTERS
// We take two arguments to this trampoline, which should be in rdi and rsi
// already. We also make sure that we stash %rax because we use that register
// to call the logging handler.
- movq ASM_TSAN_SYMBOL(_ZN6__xray22XRayPatchedCustomEventE)(%rip), %rax
+ movq ASM_SYMBOL(_ZN6__xray22XRayPatchedCustomEventE)(%rip), %rax
testq %rax,%rax
je .LcustomEventCleanup