-
Notifications
You must be signed in to change notification settings - Fork 12.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[asan] Fix dead stripping of globals on Linux (compiler-rt).
Third attempt. See the description of the corresponding commit in LLVM for more details. llvm-svn: 301588
- Loading branch information
Showing
8 changed files
with
80 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
compiler-rt/test/asan/TestCases/Linux/global-overflow-bfd.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Test that gc-sections-friendly instrumentation of globals does not introduce | ||
// false negatives with the BFD linker. | ||
// RUN: %clangxx_asan -fuse-ld=bfd -Wl,-gc-sections -ffunction-sections -fdata-sections -O0 %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}} | ||
// CHECK: {{located 0 bytes to the right of global variable}} | ||
res += XXX[argc] + ZZZ[argc]; | ||
return res; | ||
} |
19 changes: 19 additions & 0 deletions
19
compiler-rt/test/asan/TestCases/Linux/global-overflow-lld.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Test that gc-sections-friendly instrumentation of globals does not introduce | ||
// false negatives with the LLD linker. | ||
// RUN: %clangxx_asan -fuse-ld=lld -Wl,-gc-sections -ffunction-sections -fdata-sections -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s | ||
// REQUIRES: lld | ||
|
||
#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}} | ||
// CHECK: {{located 0 bytes to the right of global variable}} | ||
res += XXX[argc] + ZZZ[argc]; | ||
return res; | ||
} |
15 changes: 15 additions & 0 deletions
15
compiler-rt/test/asan/TestCases/Linux/globals-gc-sections-lld.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// RUN: %clangxx_asan %s -o %t -Wl,--gc-sections -fuse-ld=lld -ffunction-sections -fdata-sections -mllvm -asan-globals=0 | ||
// RUN: %clangxx_asan %s -o %t -Wl,--gc-sections -fuse-ld=lld -ffunction-sections -fdata-sections -mllvm -asan-globals=1 | ||
|
||
// https://code.google.com/p/address-sanitizer/issues/detail?id=260 | ||
// REQUIRES: lld | ||
|
||
int undefined(); | ||
|
||
// On i386 clang adds --export-dynamic when linking with ASan, which adds all | ||
// non-hidden globals to GC roots. | ||
__attribute__((visibility("hidden"))) int (*unused)() = undefined; | ||
|
||
int main() { | ||
return 0; | ||
} |
13 changes: 0 additions & 13 deletions
13
compiler-rt/test/asan/TestCases/Linux/globals-gc-sections.cc
This file was deleted.
Oops, something went wrong.