mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-29 15:26:07 +00:00

-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): for a data section (e.g. `.data`), if all global variables defined relative to it are unreferenced, discard them and associated `asan_globals` sections (rare but no need to exclude this case) Similar to c7b90947bd0179d914fea56b52be545c8f60f20a for PE/COFF. Reviewed By: #sanitizers, kstoimenov, vitalybuka Differential Revision: https://reviews.llvm.org/D120394
10 lines
739 B
C++
10 lines
739 B
C++
// 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=WITH-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
|
|
|
|
// WITH-GC: define internal void @asan.module_ctor() #[[#]] comdat {
|
|
// WITHOUT-GC: define internal void @asan.module_ctor() #[[#]] {
|