|
@@ -566,6 +566,13 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
|
|
|
AsanUseAfterScope = Args.hasFlag(
|
|
|
options::OPT_fsanitize_address_use_after_scope,
|
|
|
options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope);
|
|
|
+
|
|
|
+ // As a workaround for a bug in gold 2.26 and earlier, dead stripping of
|
|
|
+ // globals in ASan is disabled by default on ELF targets.
|
|
|
+ // See https://sourceware.org/bugzilla/show_bug.cgi?id=19002
|
|
|
+ AsanGlobalsDeadStripping =
|
|
|
+ !TC.getTriple().isOSBinFormatELF() ||
|
|
|
+ Args.hasArg(options::OPT_fsanitize_address_globals_dead_stripping);
|
|
|
} else {
|
|
|
AsanUseAfterScope = false;
|
|
|
}
|
|
@@ -717,6 +724,9 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
|
|
|
if (AsanUseAfterScope)
|
|
|
CmdArgs.push_back("-fsanitize-address-use-after-scope");
|
|
|
|
|
|
+ if (AsanGlobalsDeadStripping)
|
|
|
+ CmdArgs.push_back("-fsanitize-address-globals-dead-stripping");
|
|
|
+
|
|
|
// MSan: Workaround for PR16386.
|
|
|
// ASan: This is mainly to help LSan with cases such as
|
|
|
// https://code.google.com/p/address-sanitizer/issues/detail?id=373
|