MemorySanitizer does not require PIE.
Since r249754 MemorySanitizer should work equally well for PIE and
non-PIE executables on Linux/x86_64.
Beware, with this change -fsanitize=memory no longer adds implicit
-fPIE -pie compiler/linker flags on Linux/x86_64.
This is a re-land of r250941, limited to Linux/x86_64 + a very minor
refactoring in SanitizerArgs.
llvm-svn: 250949
diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp
index 8c417ef..3f1b99c 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -29,7 +29,7 @@
NeedsUbsanRt = Undefined | Integer | CFI,
NeedsUbsanCxxRt = Vptr | CFI,
NotAllowedWithTrap = Vptr,
- RequiresPIE = Memory | DataFlow,
+ RequiresPIE = DataFlow,
NeedsUnwindTables = Address | Thread | Memory | DataFlow,
SupportsCoverage = Address | Memory | Leak | Undefined | Integer | DataFlow,
RecoverableByDefault = Undefined | Integer,
@@ -164,7 +164,7 @@
}
bool SanitizerArgs::requiresPIE() const {
- return AsanZeroBaseShadow || (Sanitizers.Mask & RequiresPIE);
+ return NeedPIE || (Sanitizers.Mask & RequiresPIE);
}
bool SanitizerArgs::needsUnwindTables() const {
@@ -180,8 +180,8 @@
CoverageFeatures = 0;
MsanTrackOrigins = 0;
MsanUseAfterDtor = false;
+ NeedPIE = false;
AsanFieldPadding = 0;
- AsanZeroBaseShadow = false;
AsanSharedRuntime = false;
LinkCXXRuntimes = false;
}
@@ -424,8 +424,10 @@
}
}
}
- MsanUseAfterDtor =
- Args.hasArg(options::OPT_fsanitize_memory_use_after_dtor);
+ MsanUseAfterDtor =
+ Args.hasArg(options::OPT_fsanitize_memory_use_after_dtor);
+ NeedPIE |= !(TC.getTriple().isOSLinux() &&
+ TC.getTriple().getArch() == llvm::Triple::x86_64);
}
// Parse -f(no-)?sanitize-coverage flags if coverage is supported by the
@@ -496,7 +498,7 @@
if (AllAddedKinds & Address) {
AsanSharedRuntime =
Args.hasArg(options::OPT_shared_libasan) || TC.getTriple().isAndroid();
- AsanZeroBaseShadow = TC.getTriple().isAndroid();
+ NeedPIE |= TC.getTriple().isAndroid();
if (Arg *A =
Args.getLastArg(options::OPT_fsanitize_address_field_padding)) {
StringRef S = A->getValue();