[TSan] Support cross building. 20/159920/5
authorDenis Khalikov <d.khalikov@partner.samsung.com>
Fri, 17 Nov 2017 12:37:07 +0000 (15:37 +0300)
committerDongkyun Son <dongkyun.s@samsung.com>
Thu, 7 Dec 2017 04:59:04 +0000 (04:59 +0000)
In case we want to build binary with TSan for aarch64
CPU under qemu-user on x86_64 CPU, we should make sure
that we don't make any architecture dependent checks at
the runtime.
To support this, new flag "run_under_qemu" was added and
now available under TSAN_OPTIONS.

Change-Id: Ifad929d284d30b720afd60a60a88fa129f37d4a6

libsanitizer/tsan/tsan_flags.inc
libsanitizer/tsan/tsan_platform_linux.cc

index 78f5e80..be03755 100644 (file)
@@ -79,3 +79,4 @@ TSAN_FLAG(bool, ignore_interceptors_accesses, false,
           "Ignore reads and writes from all interceptors.")
 TSAN_FLAG(bool, shared_ptr_interceptor, true,
           "Track atomic reference counting in libc++ shared_ptr and weak_ptr.")
+TSAN_FLAG(bool, run_under_qemu, false, "Support to run under qemu.")
index 2ed5718..b47e01e 100644 (file)
@@ -270,6 +270,12 @@ void InitializePlatform() {
     // Initialize the guard pointer used in {sig}{set,long}jump.
     InitializeGuardPtr();
 #endif
+    // If we call execve for "/proc/self/exe" under qemu-user,
+    // we will get an error, because kernel will try to ReExec
+    // qemu instead of TSaned binary.
+    if (UNLIKELY(flags()->run_under_qemu))
+      return;
+
     if (reexec)
       ReExec();
   }