diff options
author | Julian Lettner <jlettner@apple.com> | 2019-07-11 18:26:33 +0000 |
---|---|---|
committer | Julian Lettner <jlettner@apple.com> | 2019-07-11 18:26:33 +0000 |
commit | 449e644b30b34b5ec2bd5d264663268d8bb5971a (patch) | |
tree | 31396423c7273a7aeedff5ad7a0ee30e99b672db | |
parent | 7d61bed8105070f122e00a0475252f9949fa0486 (diff) | |
download | compiler-rt-449e644b30b34b5ec2bd5d264663268d8bb5971a.tar.gz |
[TSan] Move DECLARE_REAL macro outside of namespace
This should fix the "undefined reference to
tsan::interception::real_setjmp" linker errors.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@365806 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/tsan/rtl/tsan_platform_linux.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/lib/tsan/rtl/tsan_platform_linux.cc b/lib/tsan/rtl/tsan_platform_linux.cc index 8db6635b1..5d9284c52 100644 --- a/lib/tsan/rtl/tsan_platform_linux.cc +++ b/lib/tsan/rtl/tsan_platform_linux.cc @@ -72,9 +72,21 @@ __tsan::uptr InitializeGuardPtr() __attribute__((visibility("hidden"))); extern "C" __tsan::uptr _tsan_pointer_chk_guard; #endif +#if SANITIZER_LINUX && defined(__aarch64__) && !SANITIZER_GO +# define INIT_LONGJMP_XOR_KEY 1 +#else +# define INIT_LONGJMP_XOR_KEY 0 +#endif + +#if INIT_LONGJMP_XOR_KEY +#include "interception/interception.h" +// Must be declared outside of other namespaces. +DECLARE_REAL(int, _setjmp, void *env) +#endif + namespace __tsan { -#if SANITIZER_LINUX && defined(__aarch64__) && !SANITIZER_GO +#if INIT_LONGJMP_XOR_KEY static void InitializeLongjmpXorKey(); static uptr longjmp_xor_key; #endif @@ -415,9 +427,7 @@ uptr ExtractLongJmpSp(uptr *env) { return UnmangleLongJmpSp(mangled_sp); } -#if SANITIZER_LINUX && defined(__aarch64__) -#include "interception/interception.h" -DECLARE_REAL(int, _setjmp, void* env) +#if INIT_LONGJMP_XOR_KEY // GLIBC mangles the function pointers in jmp_buf (used in {set,long}*jmp // functions) by XORing them with a random key. For AArch64 it is a global // variable rather than a TCB one (as for x86_64/powerpc). We obtain the key by @@ -425,7 +435,7 @@ DECLARE_REAL(int, _setjmp, void* env) static void InitializeLongjmpXorKey() { // 1. Call REAL(setjmp), which stores the mangled SP in env. jmp_buf env; - // REAL(_setjmp)(env); // TODO(yln) + REAL(_setjmp)(env); // 2. Retrieve mangled/vanilla SP. uptr mangled_sp = ((uptr *)&env)[LONG_JMP_SP_ENV_SLOT]; |