[PATCH] D26770: [asan] Make ASan compatible with linker dead stripping on Windows

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 18 10:18:58 PST 2016


rnk added inline comments.


================
Comment at: lib/Transforms/Instrumentation/AddressSanitizer.cpp:1566
+  bool UseMachOGlobalsSection = ShouldUseMachOGlobalsSection();
+  bool UseMetadataArray = !(UseComdatMetadata || UseMachOGlobalsSection);
+
----------------
inglorion wrote:
> This would make it not use comdat metadata on ELF, right? Would it work to instead do the equivalent of
> 
>   bool UseMachOGlobalsSection = ShouldUseMachOGlobalsSection();
>   bool UseComdatMetadata = !UseMachOGlobalsSection && TargetTriple.supportsCOMDAT();
>   bool UseMetadataArray = !(UseComdatMetadata || UseMachOGlobalsSection);
> 
> so that we get the MachO special implementation where applicable, else try to use comdats, and only fall back to the metadata array if neither of the other options will work?
There's a bit more work to do for ELF:
1. COMDAT groups around internal symbols don't work the way I expected, this is what my comment about "Implementing this for ELF will require extending LLVM IR and MC a bit so that we can use non-COMDAT section groups." is about. If you enable this code on ELF, you end up with "relocation against discarded section" errors for strings and other static globals.
2. Once that's all prototyped, I need to do a bit more work to verify that --gc-sections actually discards unused globals and retains asan global metadata for used globals
3. We need to add an initializer to every DSO containing asan-instrumented code to register these globals. On Windows, users are required to statically link a small bit of ASan RTL code into every DLL that uses ASan, so I put the registration code there.


https://reviews.llvm.org/D26770





More information about the llvm-commits mailing list