summaryrefslogtreecommitdiff
path: root/test/asan/lit.cfg
diff options
context:
space:
mode:
authorEtienne Bergeron <etienneb@google.com>2016-09-23 17:40:31 +0000
committerEtienne Bergeron <etienneb@google.com>2016-09-23 17:40:31 +0000
commit5ab88bf41c4f7966f23e34cd28bfd1c3ed6840de (patch)
treec2edfbc7bd7a13d81cd52c28c75439bf998f7d6d /test/asan/lit.cfg
parente1c66076eb46c8d8f55f6463938a96415fba7dc8 (diff)
[compiler-rt] Fix a broken asan 64-bit test using ld_preload
Summary: The 'asan_preload_test-1.cc' is not working with the i686 architecture. To repro the error, run on a linux 64-bit: ``` ninja check-asan-dynamic ``` The following error occurs: ``` -- Exit Code: 1 Command Output (stderr): -- /home/llvm/llvm/projects/compiler-rt/test/asan/TestCases/Linux/asan_preload_test-1.cc:18:12: error: expected string not found in input // CHECK: AddressSanitizer: heap-buffer-overflow ^ <stdin>:1:1: note: scanning from here ERROR: ld.so: object 'libclang_rt.asan-i686.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS32): ignored. ^ <stdin>:2:10: note: possible intended match here ==25982==AddressSanitizer CHECK failed: /home/llvm/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:736 "((__interception::real_memcpy)) != (0)" (0x0, 0x0) ``` The unittest is running (where %shared_libasan is replaced by libclang_rt.asan-i686.so): ``` // RUN: env LD_PRELOAD=%shared_libasan not %run %t 2>&1 | FileCheck %s ``` But the executable also has a dependancy on libclang_rt.asan-i386.so (added by the clang driver): ``` linux-gate.so.1 => (0xf77cc000) libclang_rt.asan-i386.so => not found libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xf76ba000) libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xf7673000) libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xf7656000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf74a7000) ``` By looking to the clang driver (tools.cpp) we can see that every x86 architecture are mapped to 'i386'. ``` StringRef MyArch; switch (getToolChain().getArch()) { case llvm::Triple::arm: MyArch = "arm"; break; case llvm::Triple::x86: MyArch = "i386"; break; case llvm::Triple::x86_64: MyArch = "amd64"; break; default: llvm_unreachable("Unsupported architecture"); } ``` This patch is implementing the same mapping but in the compiler-rt unittest. Reviewers: rnk, vitalybuka Subscribers: aemerson, kubabrecka, dberris, llvm-commits, chrisha Differential Revision: https://reviews.llvm.org/D24838 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282263 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/lit.cfg')
-rw-r--r--test/asan/lit.cfg7
1 files changed, 6 insertions, 1 deletions
diff --git a/test/asan/lit.cfg b/test/asan/lit.cfg
index feb851bcd..455a58ce3 100644
--- a/test/asan/lit.cfg
+++ b/test/asan/lit.cfg
@@ -104,11 +104,16 @@ else:
def build_invocation(compile_flags):
return " " + " ".join([clang_wrapper, config.clang] + compile_flags) + " "
+# Clang driver link 'x86' (i686) architecture to 'i386'.
+target_arch = config.target_arch
+if (target_arch == "i686"):
+ target_arch = "i386"
+
config.substitutions.append( ("%clang ", build_invocation(target_cflags)) )
config.substitutions.append( ("%clangxx ", build_invocation(target_cxxflags)) )
config.substitutions.append( ("%clang_asan ", build_invocation(clang_asan_cflags)) )
config.substitutions.append( ("%clangxx_asan ", build_invocation(clang_asan_cxxflags)) )
-config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % config.target_arch))
+config.substitutions.append( ("%shared_libasan", "libclang_rt.asan-%s.so" % target_arch))
if config.asan_dynamic:
config.substitutions.append( ("%clang_asan_static ", build_invocation(clang_asan_static_cflags)) )
config.substitutions.append( ("%clangxx_asan_static ", build_invocation(clang_asan_static_cxxflags)) )