diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2019-08-23 21:37:20 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2019-08-23 21:37:20 +0000 |
commit | 5b31ac509687bdcef5a29b69e930f834e26ac2f9 (patch) | |
tree | 2e2ed5f69ee301585191d35ec3cfa7b9cb15df4e | |
parent | f869ec8d4981afb18356d98a6b27c85d4e2affe3 (diff) | |
download | bcm5719-llvm-5b31ac509687bdcef5a29b69e930f834e26ac2f9.tar.gz bcm5719-llvm-5b31ac509687bdcef5a29b69e930f834e26ac2f9.zip |
hwasan: Fix use of uninitialized memory.
Reported by e.g.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/23071/steps/build%20with%20ninja/logs/stdio
llvm-svn: 369815
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index 874361d4755..8a1129aa9a0 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -369,6 +369,18 @@ void HWAddressSanitizer::initializeModule() { Int32Ty = IRB.getInt32Ty(); HwasanCtorFunction = nullptr; + + // Older versions of Android do not have the required runtime support for + // global or personality function instrumentation. On other platforms we + // currently require using the latest version of the runtime. + bool NewRuntime = + !TargetTriple.isAndroid() || !TargetTriple.isAndroidVersionLT(30); + + // If we don't have personality function support, fall back to landing pads. + InstrumentLandingPads = ClInstrumentLandingPads.getNumOccurrences() + ? ClInstrumentLandingPads + : !NewRuntime; + if (!CompileKernel) { std::tie(HwasanCtorFunction, std::ignore) = getOrCreateSanitizerCtorAndInitFunctions( @@ -383,22 +395,11 @@ void HWAddressSanitizer::initializeModule() { appendToGlobalCtors(M, Ctor, 0, Ctor); }); - // Older versions of Android do not have the required runtime support for - // global or personality function instrumentation. On other platforms we - // currently require using the latest version of the runtime. - bool NewRuntime = - !TargetTriple.isAndroid() || !TargetTriple.isAndroidVersionLT(30); - bool InstrumentGlobals = ClGlobals.getNumOccurrences() ? ClGlobals : NewRuntime; if (InstrumentGlobals) instrumentGlobals(); - // If we don't have personality function support, fall back to landing pads. - InstrumentLandingPads = ClInstrumentLandingPads.getNumOccurrences() - ? ClInstrumentLandingPads - : !NewRuntime; - bool InstrumentPersonalityFunctions = ClInstrumentPersonalityFunctions.getNumOccurrences() ? ClInstrumentPersonalityFunctions |