MaskRay created this revision. MaskRay added reviewers: Sanitizers, eugenis, kstoimenov, vitalybuka. Herald added a subscriber: ormris. MaskRay requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
-fdata-sections decides whether global variables go into different sections. This is orthogonal to whether we place their metadata (`.data` or `asan_globals`) into different sections. With -fno-data-sections, `-fsanitize-address-globals-dead-stripping` can still: - deduplicate COMDAT `asan.module_ctor` and `asan.module_dtor` - (with ld --gc-sections): discard `asan_globals` sections and associated unreferenced global variables Similar to c7b90947bd0179d914fea56b52be545c8f60f20a for PE/COFF. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D120394 Files: clang/lib/CodeGen/BackendUtil.cpp clang/test/CodeGen/asan-globals-gc.cpp clang/test/CodeGen/asan-no-globals-no-comdat.cpp Index: clang/test/CodeGen/asan-no-globals-no-comdat.cpp =================================================================== --- clang/test/CodeGen/asan-no-globals-no-comdat.cpp +++ clang/test/CodeGen/asan-no-globals-no-comdat.cpp @@ -1,8 +1,7 @@ // Test that on Linux asan constructor is placed in a comdat iff globals-gc is on. // Even if there are no globals in the module. -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC +// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC Index: clang/test/CodeGen/asan-globals-gc.cpp =================================================================== --- clang/test/CodeGen/asan-globals-gc.cpp +++ clang/test/CodeGen/asan-globals-gc.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC +// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -281,7 +281,7 @@ case Triple::COFF: return true; case Triple::ELF: - return CGOpts.DataSections && !CGOpts.DisableIntegratedAS; + return !CGOpts.DisableIntegratedAS; case Triple::GOFF: llvm::report_fatal_error("ASan not implemented for GOFF"); case Triple::XCOFF:
Index: clang/test/CodeGen/asan-no-globals-no-comdat.cpp =================================================================== --- clang/test/CodeGen/asan-no-globals-no-comdat.cpp +++ clang/test/CodeGen/asan-no-globals-no-comdat.cpp @@ -1,8 +1,7 @@ // Test that on Linux asan constructor is placed in a comdat iff globals-gc is on. // Even if there are no globals in the module. -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC +// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC Index: clang/test/CodeGen/asan-globals-gc.cpp =================================================================== --- clang/test/CodeGen/asan-globals-gc.cpp +++ clang/test/CodeGen/asan-globals-gc.cpp @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC -// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC +// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-dead-stripping -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC // RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -281,7 +281,7 @@ case Triple::COFF: return true; case Triple::ELF: - return CGOpts.DataSections && !CGOpts.DisableIntegratedAS; + return !CGOpts.DisableIntegratedAS; case Triple::GOFF: llvm::report_fatal_error("ASan not implemented for GOFF"); case Triple::XCOFF:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits