aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Instrumentation/HWAddressSanitizer.cpp')
-rw-r--r--lib/Transforms/Instrumentation/HWAddressSanitizer.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index d62598bb5d4..bc690ccd5cd 100644
--- a/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -127,6 +127,11 @@ static cl::opt<unsigned long long> ClMappingOffset(
cl::desc("HWASan shadow mapping offset [EXPERIMENTAL]"), cl::Hidden,
cl::init(0));
+static cl::opt<bool>
+ ClWithIfunc("hwasan-with-ifunc",
+ cl::desc("Access dynamic shadow through an ifunc global on "
+ "platforms that support this"),
+ cl::Hidden, cl::init(false));
namespace {
/// An instrumentation pass implementing detection of addressability bugs
@@ -751,13 +756,21 @@ void HWAddressSanitizer::ShadowMapping::init(Triple &TargetTriple) {
IsAndroid && !TargetTriple.isAndroidVersionLT(21);
Scale = kDefaultShadowScale;
+ const bool WithIfunc = ClWithIfunc.getNumOccurrences() > 0
+ ? ClWithIfunc
+ : IsAndroidWithIfuncSupport;
- if (ClEnableKhwasan || ClInstrumentWithCalls || !IsAndroidWithIfuncSupport)
+ if (ClMappingOffset.getNumOccurrences() > 0) {
+ InGlobal = false;
+ Offset = ClMappingOffset;
+ } else if (ClEnableKhwasan || ClInstrumentWithCalls) {
+ InGlobal = false;
Offset = 0;
- else
+ } else if (WithIfunc) {
+ InGlobal = true;
Offset = kDynamicShadowSentinel;
- if (ClMappingOffset.getNumOccurrences() > 0)
- Offset = ClMappingOffset;
-
- InGlobal = IsAndroidWithIfuncSupport;
+ } else {
+ InGlobal = false;
+ Offset = kDynamicShadowSentinel;
+ }
}