20 lines · cpp
1// Test that gc-sections-friendly instrumentation of globals does not introduce2// false negatives with the LLD linker.3// RUN: %clangxx_asan -fuse-ld=lld -Wl,-gc-sections -ffunction-sections -fdata-sections -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s4// REQUIRES: lld5 6#include <string.h>7int main(int argc, char **argv) {8 static char XXX[10];9 static char YYY[10];10 static char ZZZ[10];11 memset(XXX, 0, 10);12 memset(YYY, 0, 10);13 memset(ZZZ, 0, 10);14 int res = YYY[argc * 10]; // BOOOM15 // CHECK: {{READ of size 1 at}}16 // CHECK: {{located 0 bytes after global variable}}17 res += XXX[argc] + ZZZ[argc];18 return res;19}20