]> granicus.if.org Git - llvm/commit
[asan] Fix dead stripping of globals on Linux.
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 27 Apr 2017 20:27:27 +0000 (20:27 +0000)
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>
Thu, 27 Apr 2017 20:27:27 +0000 (20:27 +0000)
commit226bbc39376ff7f4d772bb51f53814ea4220a622
treed2b97401933d5c7a0f768f5301ca012d19b7a9c9
parentcd2999ea454aa0315b96c3689de9fbafa18572ed
[asan] Fix dead stripping of globals on Linux.

Use a combination of !associated, comdat, @llvm.compiler.used and
custom sections to allow dead stripping of globals and their asan
metadata. Sometimes.

Currently this works on LLD, which supports SHF_LINK_ORDER with
sh_link pointing to the associated section.

This also works on BFD, which seems to treat comdats as
all-or-nothing with respect to linker GC. There is a weird quirk
where the "first" global in each link is never GC-ed because of the
section symbols.

At this moment it does not work on Gold (as in the globals are never
stripped).

This is a second re-land of r298158. This time, this feature is
limited to -fdata-sections builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301587 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Utils/ModuleUtils.h
lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
lib/Transforms/Instrumentation/AddressSanitizer.cpp
lib/Transforms/Utils/ModuleUtils.cpp
test/Instrumentation/AddressSanitizer/global_metadata.ll
test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll
test/Instrumentation/AddressSanitizer/global_metadata_windows.ll
test/Instrumentation/AddressSanitizer/instrument_global.ll
test/Instrumentation/AddressSanitizer/no-globals.ll