[asan] Support dead code stripping on Mach-O platforms
authorRyan Govostes <rzg@apple.com>
Mon, 28 Mar 2016 20:28:57 +0000 (20:28 +0000)
committerRyan Govostes <rzg@apple.com>
Mon, 28 Mar 2016 20:28:57 +0000 (20:28 +0000)
commit653f9d0273cf44e54d4c110b1cf19ef6cfab47ba
treefe646a488c1e04d428eea1c449701cc72506c487
parentdc91fe5d8b7777942d46d5d8152a586932f13291
[asan] Support dead code stripping on Mach-O platforms

On OS X El Capitan and iOS 9, the linker supports a new section
attribute, live_support, which allows dead stripping to remove dead
globals along with the ASAN metadata about them.

With this change __asan_global structures are emitted in a new
__DATA,__asan_globals section on Darwin.

Additionally, there is a __DATA,__asan_liveness section with the
live_support attribute. Each entry in this section is simply a tuple
that binds together the liveness of a global variable and its ASAN
metadata structure. Thus the metadata structure will be alive if and
only if the global it references is also alive.

Review: http://reviews.llvm.org/D16737
llvm-svn: 264645
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/test/Instrumentation/AddressSanitizer/global_metadata.ll
llvm/test/Instrumentation/AddressSanitizer/global_metadata_darwin.ll [new file with mode: 0644]