[compiler-rt] r330990 - [asan] Align __asan_global_start so that it works with LLD
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 26 13:46:50 PDT 2018
Author: rnk
Date: Thu Apr 26 13:46:50 2018
New Revision: 330990
URL: http://llvm.org/viewvc/llvm-project?rev=330990&view=rev
Log:
[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
Added:
compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld-globals.cc
Modified:
compiler-rt/trunk/lib/asan/asan_globals_win.cc
Modified: compiler-rt/trunk/lib/asan/asan_globals_win.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_globals_win.cc?rev=330990&r1=330989&r2=330990&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_globals_win.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_globals_win.cc Thu Apr 26 13:46:50 2018
@@ -19,9 +19,9 @@ namespace __asan {
#pragma section(".ASAN$GA", read, write) // NOLINT
#pragma section(".ASAN$GZ", read, write) // NOLINT
extern "C" __declspec(allocate(".ASAN$GA"))
-__asan_global __asan_globals_start = {};
+ ALIGNED(sizeof(__asan_global)) __asan_global __asan_globals_start = {};
extern "C" __declspec(allocate(".ASAN$GZ"))
-__asan_global __asan_globals_end = {};
+ ALIGNED(sizeof(__asan_global)) __asan_global __asan_globals_end = {};
#pragma comment(linker, "/merge:.ASAN=.data")
static void call_on_globals(void (*hook)(__asan_global *, uptr)) {
Added: compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld-globals.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld-globals.cc?rev=330990&view=auto
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld-globals.cc (added)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/fuse-lld-globals.cc Thu Apr 26 13:46:50 2018
@@ -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;
+}
More information about the llvm-commits
mailing list