[PATCH] Add compiler support for dynamic Asan runtime
Alexey Samsonov
samsonov at google.com
Fri Mar 21 01:47:21 PDT 2014
Please rebase the patch before uploading the next diff.
================
Comment at: lib/Driver/Tools.cpp:1873
@@ -1860,3 +1872,3 @@
} else {
- if (!Args.hasArg(options::OPT_shared))
- addSanitizerRTLinkFlags(TC, Args, CmdArgs, "asan", true);
+ bool Executable = !Args.hasArg(options::OPT_shared);
+
----------------
The logic is still non-understandable. Please find a better way to express it. As a suggestion:
if (NeedsSharedRT) {
// add asan-dynamic.so to the link line.
}
if (Args.hasArg(options::OPT_shared)) {
return; // don't link static parts into shared objects.
}
StringRef AsanStaticPart = NeedsSharedRT ? "asan-preinit" : "asan";
bool BeforeLibStdCXX = true;
bool ExportSymbols = !NeedsSharedRT;
addSanitizerRTLinkFlags(TC, Args, CmdArgs, AsanStaticPart, BeforeLibStdCXX, ExportSymbols);
now, if you don't want do add "-ldl lpthread -lrt -lm" to the link line for executable and -shared-libasan mode, you may add one more
flag to control whether you add these libs or not. Or, as an alternative, factor adding "-ldl ..." to a separate function and call it when necessary.
http://llvm-reviews.chandlerc.com/D3043
More information about the llvm-commits
mailing list