summaryrefslogtreecommitdiff
path: root/test/asan
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-04-26 20:46:50 +0000
committerReid Kleckner <rnk@google.com>2018-04-26 20:46:50 +0000
commit180743bbb38fc7ad7fdc0026716dffa64c19fb63 (patch)
tree7d50ddb400708950fff4fad42e1677e8552e35fe /test/asan
parente47560819c50ca19422b837e8fa076ca32096ef5 (diff)
[asan] Align __asan_global_start so that it works with LLD
Otherwise LLD will not align the .ASAN$GA section start, and &__asan_globals + 1 will not be the start of the next real ASan global metadata in .ASAN$GL. We discovered this issue when attempting to use LLD on Windows in Chromium: https://crbug.com/837090 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@330990 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan')
-rw-r--r--test/asan/TestCases/Windows/fuse-lld-globals.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/test/asan/TestCases/Windows/fuse-lld-globals.cc b/test/asan/TestCases/Windows/fuse-lld-globals.cc
new file mode 100644
index 000000000..4148d562f
--- /dev/null
+++ b/test/asan/TestCases/Windows/fuse-lld-globals.cc
@@ -0,0 +1,18 @@
+// RUN: %clangxx_asan -fuse-ld=lld -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
+
+#include <string.h>
+int main(int argc, char **argv) {
+ static char XXX[10];
+ static char YYY[10];
+ static char ZZZ[10];
+ memset(XXX, 0, 10);
+ memset(YYY, 0, 10);
+ memset(ZZZ, 0, 10);
+ int res = YYY[argc * 10]; // BOOOM
+ // CHECK: {{READ of size 1 at 0x.* thread T0}}
+ // CHECK: {{ #0 0x.* in main .*fuse-lld-globals.cc:}}[[@LINE-2]]
+ // CHECK: {{0x.* is located 0 bytes to the right of global variable}}
+ // CHECK: {{.*YYY.* of size 10}}
+ res += XXX[argc] + ZZZ[argc];
+ return res;
+}