Skip to content

Commit c7b9094

Browse files
committed
[asan] Unconditionally enable GC of globals on COFF.
This change restores pre-r301225 behavior, where linker GC compatible global instrumentation was used on COFF targets disregarding -f(no-)data-sections and/or /Gw flags. This instrumentation puts each global in a COMDAT with an ASan descriptor for that global. It effectively enables -fdata-sections, but limits it to ASan-instrumented globals. llvm-svn: 301374
1 parent 9547aab commit c7b9094

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,8 @@ static void addSanitizerCoveragePass(const PassManagerBuilder &Builder,
196196
static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) {
197197
switch (T.getObjectFormat()) {
198198
case Triple::MachO:
199-
return true;
200199
case Triple::COFF:
201-
return CGOpts.DataSections;
200+
return true;
202201
case Triple::ELF:
203202
return CGOpts.DataSections && !CGOpts.DisableIntegratedAS;
204203
default:

clang/test/CodeGen/asan-globals-gc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
1+
// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
22
// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
33

44
int global;

0 commit comments

Comments
 (0)