[compiler-rt] r365806 - [TSan] Move DECLARE_REAL macro outside of namespace

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 11:26:33 PDT 2019


Author: yln
Date: Thu Jul 11 11:26:33 2019
New Revision: 365806

URL: http://llvm.org/viewvc/llvm-project?rev=365806&view=rev
Log:
[TSan] Move DECLARE_REAL macro outside of namespace

This should fix the "undefined reference to
tsan::interception::real_setjmp" linker errors.

Modified:
    compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc

Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc?rev=365806&r1=365805&r2=365806&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_platform_linux.cc Thu Jul 11 11:26:33 2019
@@ -72,9 +72,21 @@ __tsan::uptr InitializeGuardPtr() __attr
 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];




More information about the llvm-commits mailing list