summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-08-10 16:21:37 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2018-08-10 16:21:37 +0000
commit453e7ac785fee20f5113f3b219391f92b045adc5 (patch)
tree722716301fc069213c41950ec23c080e6182ab7c /llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
parentc9cc86a5b31a0cb4600ca7ef31a266b6b4420afe (diff)
downloadbcm5719-llvm-453e7ac785fee20f5113f3b219391f92b045adc5.tar.gz
bcm5719-llvm-453e7ac785fee20f5113f3b219391f92b045adc5.zip
[hwasan] Add -hwasan-with-ifunc flag.
Summary: Similar to asan's flag, it can be used to disable the use of ifunc to access hwasan shadow address. Reviewers: vitalybuka, kcc Subscribers: srhines, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D50544 llvm-svn: 339447
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp')
-rw-r--r--llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index d62598bb5d4..bc690ccd5cd 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/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;
+ }
}
OpenPOWER on IntegriCloud