summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmake/config-ix.cmake13
-rw-r--r--lib/xray/CMakeLists.txt45
-rw-r--r--lib/xray/tests/CMakeLists.txt37
-rw-r--r--lib/xray/weak_symbols.txt4
-rw-r--r--lib/xray/xray_init.cc3
-rw-r--r--lib/xray/xray_trampoline_x86_64.S97
-rw-r--r--test/xray/TestCases/Darwin/always-never-instrument.cc23
-rw-r--r--test/xray/TestCases/Darwin/lit.local.cfg9
-rw-r--r--test/xray/TestCases/Linux/lit.local.cfg9
-rw-r--r--test/xray/lit.cfg2
10 files changed, 64 insertions, 178 deletions
diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake
index b8f888a54..30b308131 100644
--- a/cmake/config-ix.cmake
+++ b/cmake/config-ix.cmake
@@ -211,11 +211,7 @@ set(ALL_SAFESTACK_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM64} ${MIPS32} ${MIPS64})
set(ALL_CFI_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS64})
set(ALL_ESAN_SUPPORTED_ARCH ${X86_64} ${MIPS64})
set(ALL_SCUDO_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64})
-if(APPLE)
-set(ALL_XRAY_SUPPORTED_ARCH ${X86_64})
-else()
set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64} powerpc64le)
-endif()
if(APPLE)
include(CompilerRTDarwinUtils)
@@ -260,7 +256,6 @@ if(APPLE)
set(SANITIZER_COMMON_SUPPORTED_OS osx)
set(PROFILE_SUPPORTED_OS osx)
set(TSAN_SUPPORTED_OS osx)
- set(XRAY_SUPPORTED_OS osx)
if(NOT SANITIZER_MIN_OSX_VERSION)
string(REGEX MATCH "-mmacosx-version-min=([.0-9]+)"
MACOSX_VERSION_MIN_FLAG "${CMAKE_CXX_FLAGS}")
@@ -417,12 +412,12 @@ if(APPLE)
list_intersect(SCUDO_SUPPORTED_ARCH
ALL_SCUDO_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
- list_intersect(FUZZER_SUPPORTED_ARCH
- ALL_FUZZER_SUPPORTED_ARCH
- ALL_SANITIZER_COMMON_SUPPORTED_ARCH)
list_intersect(XRAY_SUPPORTED_ARCH
ALL_XRAY_SUPPORTED_ARCH
SANITIZER_COMMON_SUPPORTED_ARCH)
+ list_intersect(FUZZER_SUPPORTED_ARCH
+ ALL_FUZZER_SUPPORTED_ARCH
+ ALL_SANITIZER_COMMON_SUPPORTED_ARCH)
else()
# Architectures supported by compiler-rt libraries.
@@ -585,7 +580,7 @@ else()
endif()
if (COMPILER_RT_HAS_SANITIZER_COMMON AND XRAY_SUPPORTED_ARCH AND
- OS_NAME MATCHES "Darwin|Linux")
+ OS_NAME MATCHES "Linux")
set(COMPILER_RT_HAS_XRAY TRUE)
else()
set(COMPILER_RT_HAS_XRAY FALSE)
diff --git a/lib/xray/CMakeLists.txt b/lib/xray/CMakeLists.txt
index 101be97d2..6d24ba8bf 100644
--- a/lib/xray/CMakeLists.txt
+++ b/lib/xray/CMakeLists.txt
@@ -65,53 +65,19 @@ append_list_if(
append_list_if(
COMPILER_RT_BUILD_XRAY_NO_PREINIT XRAY_NO_PREINIT XRAY_COMMON_DEFINITIONS)
+add_compiler_rt_object_libraries(RTXray
+ ARCHS ${XRAY_SUPPORTED_ARCH}
+ SOURCES ${XRAY_SOURCES} CFLAGS ${XRAY_CFLAGS}
+ DEFS ${XRAY_COMMON_DEFINITIONS})
+
add_compiler_rt_component(xray)
set(XRAY_COMMON_RUNTIME_OBJECT_LIBS
- RTXray
RTSanitizerCommon
RTSanitizerCommonLibc)
-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_weak_symbols("sanitizer_common" WEAK_SYMBOL_LINK_FLAGS)
- add_weak_symbols("xray" WEAK_SYMBOL_LINK_FLAGS)
-
- add_compiler_rt_object_libraries(RTXray
- OS ${XRAY_SUPPORTED_OS}
- ARCHS ${XRAY_SUPPORTED_ARCH}
- SOURCES ${x86_64_SOURCES}
- CFLAGS ${XRAY_CFLAGS}
- DEFS ${XRAY_COMMON_DEFINITIONS})
-
- # We only support running on osx for now.
- add_compiler_rt_runtime(clang_rt.xray
- STATIC
- OS ${XRAY_SUPPORTED_OS}
- ARCHS ${XRAY_SUPPORTED_ARCH}
- OBJECT_LIBS RTXray
- RTSanitizerCommon
- RTSanitizerCommonLibc
- CFLAGS ${XRAY_CFLAGS}
- DEFS ${XRAY_COMMON_DEFINITIONS}
- LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
- LINK_LIBS ${XRAY_LINK_LIBS}
- PARENT_TARGET xray)
-else()
foreach(arch ${XRAY_SUPPORTED_ARCH})
if(CAN_TARGET_${arch})
- add_compiler_rt_object_libraries(RTXray
- ARCHS ${XRAY_SUPPORTED_ARCH}
- SOURCES ${XRAY_SOURCES} CFLAGS ${XRAY_CFLAGS}
- DEFS ${XRAY_COMMON_DEFINITIONS})
add_compiler_rt_runtime(clang_rt.xray
STATIC
ARCHS ${arch}
@@ -122,7 +88,6 @@ foreach(arch ${XRAY_SUPPORTED_ARCH})
PARENT_TARGET xray)
endif()
endforeach()
-endif()
if(COMPILER_RT_INCLUDE_TESTS)
add_subdirectory(tests)
diff --git a/lib/xray/tests/CMakeLists.txt b/lib/xray/tests/CMakeLists.txt
index e2640b40f..e54e63f27 100644
--- a/lib/xray/tests/CMakeLists.txt
+++ b/lib/xray/tests/CMakeLists.txt
@@ -12,50 +12,21 @@ set(XRAY_UNITTEST_CFLAGS
-I${COMPILER_RT_SOURCE_DIR}/lib)
set(XRAY_TEST_ARCH ${XRAY_SUPPORTED_ARCH})
-set(XRAY_LINK_FLAGS)
-append_list_if(COMPILER_RT_HAS_LIBRT -lrt XRAY_LINK_FLAGS)
-append_list_if(COMPILER_RT_HAS_LIBM -lm XRAY_LINK_FLAGS)
-append_list_if(COMPILER_RT_HAS_LIBPTHREAD -lpthread XRAY_LINK_FLAGS)
-
-if (APPLE)
- list(APPEND XRAY_LINK_FLAGS -lc++)
- list(APPEND XRAY_LINK_FLAGS ${SANITIZER_COMMON_LINK_FLAGS})
- set(XRAY_TEST_RUNTIME_OBJECTS
- $<TARGET_OBJECTS:RTSanitizerCommon.osx>
- $<TARGET_OBJECTS:RTSanitizerCommonLibc.osx>
- $<TARGET_OBJECTS:RTXray.osx>)
- set(XRAY_TEST_RUNTIME RTXRayTest)
- add_library(${XRAY_TEST_RUNTIME} STATIC ${XRAY_TEST_RUNTIME_OBJECTS})
- set_target_properties(${XRAY_TEST_RUNTIME} PROPERTIES
- ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- FOLDER "Compiler-RT Runtime tests")
-
- darwin_filter_host_archs(XRAY_SUPPORTED_ARCH XRAY_TEST_ARCH)
- list(APPEND XRAY_UNITTEST_CFLAGS ${DARWIN_osx_CFLAGS})
- list(APPEND XRAY_LINK_FLAGS "-lc++")
- list(APPEND XRAY_LINK_FLAGS "-fxray-instrument")
- add_weak_symbols("sanitizer_common" XRAY_LINK_FLAGS)
- add_weak_symbols("xray" XRAY_LINK_FLAGS)
-else()
- append_list_if(COMPILER_RT_HAS_LIBSTDCXX lstdc++ XRAY_LINK_FLAGS)
-endif()
-
macro(add_xray_unittest testname)
cmake_parse_arguments(TEST "" "" "SOURCES;HEADERS" ${ARGN})
- if(UNIX)
+ if(UNIX AND NOT APPLE)
foreach(arch ${XRAY_TEST_ARCH})
set(TEST_OBJECTS)
generate_compiler_rt_tests(TEST_OBJECTS
XRayUnitTests "${testname}-${arch}-Test" "${arch}"
SOURCES ${TEST_SOURCES} ${COMPILER_RT_GTEST_SOURCE}
- RUNTIME ${XRAY_TEST_RUNTIME}
- COMPILE_DEPS ${TEST_HEADERS}
DEPS gtest xray llvm-xray
CFLAGS ${XRAY_UNITTEST_CFLAGS}
LINK_FLAGS -fxray-instrument
${TARGET_LINK_FLAGS}
- ${CMAKE_THREAD_LIBS_INIT}
- ${XRAY_LINK_FLAGS})
+ -lstdc++ -lm ${CMAKE_THREAD_LIBS_INIT}
+ -lpthread
+ -ldl -lrt)
set_target_properties(XRayUnitTests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endforeach()
endif()
diff --git a/lib/xray/weak_symbols.txt b/lib/xray/weak_symbols.txt
deleted file mode 100644
index 963fff2d6..000000000
--- a/lib/xray/weak_symbols.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-___start_xray_fn_idx
-___start_xray_instr_map
-___stop_xray_fn_idx
-___stop_xray_instr_map
diff --git a/lib/xray/xray_init.cc b/lib/xray/xray_init.cc
index 864e77944..07f692431 100644
--- a/lib/xray/xray_init.cc
+++ b/lib/xray/xray_init.cc
@@ -88,8 +88,7 @@ void __xray_init() XRAY_NEVER_INSTRUMENT {
#endif
}
-// Only add the preinit array initialization if the sanitizers can.
-#if !defined(XRAY_NO_PREINIT) && SANITIZER_CAN_USE_PREINIT_ARRAY
+#ifndef XRAY_NO_PREINIT
__attribute__((section(".preinit_array"),
used)) void (*__local_xray_preinit)(void) = __xray_init;
#endif
diff --git a/lib/xray/xray_trampoline_x86_64.S b/lib/xray/xray_trampoline_x86_64.S
index bf8ca75ca..ffbfb5c7e 100644
--- a/lib/xray/xray_trampoline_x86_64.S
+++ b/lib/xray/xray_trampoline_x86_64.S
@@ -14,13 +14,10 @@
//===----------------------------------------------------------------------===//
#include "../builtins/assembly.h"
-#include "../sanitizer_common/sanitizer_asm.h"
-
-
.macro SAVE_REGISTERS
subq $192, %rsp
- CFI_DEF_CFA_OFFSET(200)
+ .cfi_def_cfa_offset 200
// At this point, the stack pointer should be aligned to an 8-byte boundary,
// because any call instructions that come after this will add another 8
// bytes and therefore align it to 16-bytes.
@@ -60,28 +57,25 @@
movq 8(%rsp), %r8
movq 0(%rsp), %r9
addq $192, %rsp
- CFI_DEF_CFA_OFFSET(8)
+ .cfi_def_cfa_offset 8
.endm
-#if !defined(__APPLE__)
- .section .text
-#else
- .section __TEXT,__text
-#endif
+ .text
.file "xray_trampoline_x86.S"
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_FunctionEntry)
+ .globl __xray_FunctionEntry
.align 16, 0x90
- ASM_TYPE_FUNCTION(__xray_FunctionEntry)
-ASM_TSAN_SYMBOL(__xray_FunctionEntry):
- CFI_STARTPROC
+ .type __xray_FunctionEntry,@function
+
+__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 _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
testq %rax, %rax
je .Ltmp0
@@ -92,27 +86,28 @@ ASM_TSAN_SYMBOL(__xray_FunctionEntry):
.Ltmp0:
RESTORE_REGISTERS
retq
- ASM_SIZE(__xray_FunctionEntry)
- CFI_ENDPROC
+.Ltmp1:
+ .size __xray_FunctionEntry, .Ltmp1-__xray_FunctionEntry
+ .cfi_endproc
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_FunctionExit)
+ .globl __xray_FunctionExit
.align 16, 0x90
- ASM_TYPE_FUNCTION(__xray_FunctionExit)
-ASM_TSAN_SYMBOL(__xray_FunctionExit):
- CFI_STARTPROC
+ .type __xray_FunctionExit,@function
+__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
// returning.
subq $56, %rsp
- CFI_DEF_CFA_OFFSET(64)
+ .cfi_def_cfa_offset 64
movq %rbp, 48(%rsp)
movupd %xmm0, 32(%rsp)
movupd %xmm1, 16(%rsp)
movq %rax, 8(%rsp)
movq %rdx, 0(%rsp)
- movq ASM_TSAN_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
+ movq _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
testq %rax,%rax
je .Ltmp2
@@ -127,21 +122,22 @@ ASM_TSAN_SYMBOL(__xray_FunctionExit):
movq 8(%rsp), %rax
movq 0(%rsp), %rdx
addq $56, %rsp
- CFI_DEF_CFA_OFFSET(8)
+ .cfi_def_cfa_offset 8
retq
- ASM_SIZE(__xray_FunctionExit)
- CFI_ENDPROC
+.Ltmp3:
+ .size __xray_FunctionExit, .Ltmp3-__xray_FunctionExit
+ .cfi_endproc
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_FunctionTailExit)
+ .global __xray_FunctionTailExit
.align 16, 0x90
- ASM_TYPE_FUNCTION(__xray_FunctionTailExit)
-ASM_TSAN_SYMBOL(__xray_FunctionTailExit):
- CFI_STARTPROC
+ .type __xray_FunctionTailExit,@function
+__xray_FunctionTailExit:
+ .cfi_startproc
SAVE_REGISTERS
- movq ASM_TSAN_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)(%rip), %rax
+ movq _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
testq %rax,%rax
je .Ltmp4
@@ -152,25 +148,26 @@ ASM_TSAN_SYMBOL(__xray_FunctionTailExit):
.Ltmp4:
RESTORE_REGISTERS
retq
- ASM_SIZE(__xray_FunctionTailExit)
- CFI_ENDPROC
+.Ltmp5:
+ .size __xray_FunctionTailExit, .Ltmp5-__xray_FunctionTailExit
+ .cfi_endproc
//===----------------------------------------------------------------------===//
- .globl ASM_TSAN_SYMBOL(__xray_ArgLoggerEntry)
+ .globl __xray_ArgLoggerEntry
.align 16, 0x90
- ASM_TYPE_FUNCTION(__xray_ArgLoggerEntry)
-ASM_TSAN_SYMBOL(__xray_ArgLoggerEntry):
- CFI_STARTPROC
+ .type __xray_ArgLoggerEntry,@function
+__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 _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 _ZN6__xray19XRayPatchedFunctionE(%rip), %rax
testq %rax, %rax
je .Larg1entryFail
@@ -189,22 +186,24 @@ ASM_TSAN_SYMBOL(__xray_ArgLoggerEntry):
.Larg1entryFail:
RESTORE_REGISTERS
retq
- ASM_SIZE(__xray_ArgLoggerEntry)
- CFI_ENDPROC
+
+.Larg1entryEnd:
+ .size __xray_ArgLoggerEntry, .Larg1entryEnd-__xray_ArgLoggerEntry
+ .cfi_endproc
//===----------------------------------------------------------------------===//
- .global ASM_TSAN_SYMBOL(__xray_CustomEvent)
+ .global __xray_CustomEvent
.align 16, 0x90
- ASM_TYPE_FUNCTION(__xray_CustomEvent)
-ASM_TSAN_SYMBOL(__xray_CustomEvent):
- CFI_STARTPROC
+ .type __xray_CustomEvent,@function
+__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 _ZN6__xray22XRayPatchedCustomEventE(%rip), %rax
testq %rax,%rax
je .LcustomEventCleanup
@@ -224,7 +223,9 @@ ASM_TSAN_SYMBOL(__xray_CustomEvent):
.LcustomEventCleanup:
RESTORE_REGISTERS
retq
- ASM_SIZE(__xray_CustomEvent)
- CFI_ENDPROC
+
+.Ltmp8:
+ .size __xray_CustomEvent, .Ltmp8-__xray_CustomEvent
+ .cfi_endproc
NO_EXEC_STACK_DIRECTIVE
diff --git a/test/xray/TestCases/Darwin/always-never-instrument.cc b/test/xray/TestCases/Darwin/always-never-instrument.cc
deleted file mode 100644
index 4e196859b..000000000
--- a/test/xray/TestCases/Darwin/always-never-instrument.cc
+++ /dev/null
@@ -1,23 +0,0 @@
-// Test that the always/never instrument lists apply.
-// RUN: echo "fun:main" > %tmp-always.txt
-// RUN: echo "fun:__xray*" > %tmp-never.txt
-// RUN: %clangxx_xray \
-// RUN: -fxray-never-instrument=%tmp-never.txt \
-// RUN: -fxray-always-instrument=%tmp-always.txt \
-// RUN: %s -o %t
-// RUN: %llvm_xray extract -symbolize %t | \
-// RUN: FileCheck %s --check-prefix NOINSTR
-// RUN: %llvm_xray extract -symbolize %t | \
-// RUN: FileCheck %s --check-prefix ALWAYSINSTR
-// REQUIRES: x86_64-linux
-// REQUIRES: built-in-llvm-tree
-
-// NOINSTR-NOT: {{.*__xray_NeverInstrumented.*}}
-int __xray_NeverInstrumented() {
- return 0;
-}
-
-// ALWAYSINSTR: {{.*function-name:.*main.*}}
-int main(int argc, char *argv[]) {
- return __xray_NeverInstrumented();
-}
diff --git a/test/xray/TestCases/Darwin/lit.local.cfg b/test/xray/TestCases/Darwin/lit.local.cfg
deleted file mode 100644
index a85dfcd24..000000000
--- a/test/xray/TestCases/Darwin/lit.local.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-def getRoot(config):
- if not config.parent:
- return config
- return getRoot(config.parent)
-
-root = getRoot(config)
-
-if root.host_os not in ['Darwin']:
- config.unsupported = True
diff --git a/test/xray/TestCases/Linux/lit.local.cfg b/test/xray/TestCases/Linux/lit.local.cfg
deleted file mode 100644
index 57271b807..000000000
--- a/test/xray/TestCases/Linux/lit.local.cfg
+++ /dev/null
@@ -1,9 +0,0 @@
-def getRoot(config):
- if not config.parent:
- return config
- return getRoot(config.parent)
-
-root = getRoot(config)
-
-if root.host_os not in ['Linux']:
- config.unsupported = True
diff --git a/test/xray/lit.cfg b/test/xray/lit.cfg
index c6bea52b1..d5e40975d 100644
--- a/test/xray/lit.cfg
+++ b/test/xray/lit.cfg
@@ -40,7 +40,7 @@ config.substitutions.append(
# Default test suffixes.
config.suffixes = ['.c', '.cc', '.cpp']
-if config.host_os not in ['Linux', 'Darwin']:
+if config.host_os not in ['Linux']:
config.unsupported = True
elif '64' not in config.host_arch:
if 'arm' in config.host_arch: