[compiler-rt] 5f5a0bb - [asan][test] Use --image-base for Linux/asan_prelink_test.cpp if ld is LLD

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 7 14:45:34 PDT 2020


Author: Fangrui Song
Date: 2020-09-07T14:45:21-07:00
New Revision: 5f5a0bb0872a9673bad08b38bc0b14c42263902a

URL: https://github.com/llvm/llvm-project/commit/5f5a0bb0872a9673bad08b38bc0b14c42263902a
DIFF: https://github.com/llvm/llvm-project/commit/5f5a0bb0872a9673bad08b38bc0b14c42263902a.diff

LOG: [asan][test] Use --image-base for Linux/asan_prelink_test.cpp if ld is LLD

LLD supports -Ttext but with the option there is still a PT_LOAD at address zero
and thus the Linux kernel will map it to a different address and the test will fail.

Use --image-base instead.

Added: 
    

Modified: 
    compiler-rt/test/asan/TestCases/Linux/asan_prelink_test.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/asan/TestCases/Linux/asan_prelink_test.cpp b/compiler-rt/test/asan/TestCases/Linux/asan_prelink_test.cpp
index e00c215e92b1..9c70b61291b3 100644
--- a/compiler-rt/test/asan/TestCases/Linux/asan_prelink_test.cpp
+++ b/compiler-rt/test/asan/TestCases/Linux/asan_prelink_test.cpp
@@ -1,11 +1,12 @@
 // Test if asan works with prelink.
-// It does not actually use prelink, but relies on ld's flag -Ttext-segment
-// or gold's flag -Ttext (we try the first flag first, if that fails we
+// It does not actually use prelink, but relies on GNU ld's -Ttext-segment,
+// LLD's --image-base, or gold's -Ttext (we try the first flag first, if that fails we
 // try the second flag).
 //
 // RUN: %clangxx_asan -c %s -o %t.o
 // RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -Wl,-Ttext-segment=0x3600000000 ||\
-// RUN: %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -Wl,-Ttext=0x3600000000
+// RUN:   %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -Wl,--image-base=0x3600000000 ||\
+// RUN:   %clangxx_asan -DBUILD_SO=1 -fPIC -shared %s -o %t.so -Wl,-Ttext=0x3600000000
 // RUN: %clangxx_asan %t.o %t.so -Wl,-R. -o %t
 // RUN: %env_asan_opts=verbosity=1 %run %t 2>&1 | FileCheck %s
 


        


More information about the llvm-commits mailing list