|
LLVM
10.0.0
|
This file is a part of HWAddressSanitizer, an address sanity checker based on tagged addressing. More...
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"#include "llvm/ADT/MapVector.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/StringExtras.h"#include "llvm/ADT/StringRef.h"#include "llvm/ADT/Triple.h"#include "llvm/BinaryFormat/ELF.h"#include "llvm/IR/Attributes.h"#include "llvm/IR/BasicBlock.h"#include "llvm/IR/Constant.h"#include "llvm/IR/Constants.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DebugInfoMetadata.h"#include "llvm/IR/DerivedTypes.h"#include "llvm/IR/Function.h"#include "llvm/IR/IRBuilder.h"#include "llvm/IR/InlineAsm.h"#include "llvm/IR/InstVisitor.h"#include "llvm/IR/Instruction.h"#include "llvm/IR/Instructions.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Intrinsics.h"#include "llvm/IR/LLVMContext.h"#include "llvm/IR/MDBuilder.h"#include "llvm/IR/Module.h"#include "llvm/IR/Type.h"#include "llvm/IR/Value.h"#include "llvm/InitializePasses.h"#include "llvm/Pass.h"#include "llvm/Support/Casting.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Instrumentation.h"#include "llvm/Transforms/Utils/BasicBlockUtils.h"#include "llvm/Transforms/Utils/ModuleUtils.h"#include "llvm/Transforms/Utils/PromoteMemToReg.h"#include <sstream>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "hwasan" |
Functions | |
| INITIALIZE_PASS_BEGIN (HWAddressSanitizerLegacyPass, "hwasan", "HWAddressSanitizer: detect memory bugs using tagged addressing.", false, false) INITIALIZE_PASS_END(HWAddressSanitizerLegacyPass | |
| static unsigned | getPointerOperandIndex (Instruction *I) |
| static size_t | TypeSizeToSizeIndex (uint32_t TypeSize) |
| static uint64_t | getAllocaSizeInBytes (const AllocaInst &AI) |
| static unsigned | RetagMask (unsigned AllocaNo) |
Variables | |
| static const char *const | kHwasanModuleCtorName = "hwasan.module_ctor" |
| static const char *const | kHwasanNoteName = "hwasan.note" |
| static const char *const | kHwasanInitName = "__hwasan_init" |
| static const char *const | kHwasanPersonalityThunkName |
| static const char *const | kHwasanShadowMemoryDynamicAddress |
| static const size_t | kNumberOfAccessSizes = 5 |
| static const size_t | kDefaultShadowScale = 4 |
| static const uint64_t | kDynamicShadowSentinel |
| static const unsigned | kPointerTagShift = 56 |
| static const unsigned | kShadowBaseAlignment = 32 |
| static cl::opt< std::string > | ClMemoryAccessCallbackPrefix ("hwasan-memory-access-callback-prefix", cl::desc("Prefix for memory access callbacks"), cl::Hidden, cl::init("__hwasan_")) |
| static cl::opt< bool > | ClInstrumentWithCalls ("hwasan-instrument-with-calls", cl::desc("instrument reads and writes with callbacks"), cl::Hidden, cl::init(false)) |
| static cl::opt< bool > | ClInstrumentReads ("hwasan-instrument-reads", cl::desc("instrument read instructions"), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClInstrumentWrites ("hwasan-instrument-writes", cl::desc("instrument write instructions"), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClInstrumentAtomics ("hwasan-instrument-atomics", cl::desc("instrument atomic instructions (rmw, cmpxchg)"), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClRecover ("hwasan-recover", cl::desc("Enable recovery mode (continue-after-error)."), cl::Hidden, cl::init(false)) |
| static cl::opt< bool > | ClInstrumentStack ("hwasan-instrument-stack", cl::desc("instrument stack (allocas)"), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClUARRetagToZero ("hwasan-uar-retag-to-zero", cl::desc("Clear alloca tags before returning from the function to allow " "non-instrumented and instrumented function calls mix. When set " "to false, allocas are retagged before returning from the " "function to detect use after return."), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClGenerateTagsWithCalls ("hwasan-generate-tags-with-calls", cl::desc("generate new tags with runtime library calls"), cl::Hidden, cl::init(false)) |
| static cl::opt< bool > | ClGlobals ("hwasan-globals", cl::desc("Instrument globals"), cl::Hidden, cl::init(false)) |
| static cl::opt< int > | ClMatchAllTag ("hwasan-match-all-tag", cl::desc("don't report bad accesses via pointers with this tag"), cl::Hidden, cl::init(-1)) |
| static cl::opt< bool > | ClEnableKhwasan ("hwasan-kernel", cl::desc("Enable KernelHWAddressSanitizer instrumentation"), cl::Hidden, cl::init(false)) |
| static cl::opt< uint64_t > | ClMappingOffset ("hwasan-mapping-offset", 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)) |
| static cl::opt< bool > | ClWithTls ("hwasan-with-tls", cl::desc("Access dynamic shadow through an thread-local pointer on " "platforms that support this"), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClRecordStackHistory ("hwasan-record-stack-history", cl::desc("Record stack frames with tagged allocations " "in a thread-local ring buffer"), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClInstrumentMemIntrinsics ("hwasan-instrument-mem-intrinsics", cl::desc("instrument memory intrinsics"), cl::Hidden, cl::init(true)) |
| static cl::opt< bool > | ClInstrumentLandingPads ("hwasan-instrument-landing-pads", cl::desc("instrument landing pads"), cl::Hidden, cl::init(false), cl::ZeroOrMore) |
| static cl::opt< bool > | ClUseShortGranules ("hwasan-use-short-granules", cl::desc("use short granules in allocas and outlined checks"), cl::Hidden, cl::init(false), cl::ZeroOrMore) |
| static cl::opt< bool > | ClInstrumentPersonalityFunctions ("hwasan-instrument-personality-functions", cl::desc("instrument personality functions"), cl::Hidden, cl::init(false), cl::ZeroOrMore) |
| static cl::opt< bool > | ClInlineAllChecks ("hwasan-inline-all-checks", cl::desc("inline all checks"), cl::Hidden, cl::init(false)) |
| hwasan | |
| HWAddressSanitizer | __pad0__ |
| HWAddressSanitizer | false |
This file is a part of HWAddressSanitizer, an address sanity checker based on tagged addressing.
Definition in file HWAddressSanitizer.cpp.
| #define DEBUG_TYPE "hwasan" |
Definition at line 55 of file HWAddressSanitizer.cpp.
|
static |
Definition at line 759 of file HWAddressSanitizer.cpp.
References llvm::alignTo(), assert(), ClInstrumentWithCalls, llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateConstGEP1_32(), llvm::IRBuilderBase::CreateMemSet(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::IRBuilder< T, Inserter >::CreateStore(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::dyn_cast(), llvm::ConstantInt::get(), llvm::AllocaInst::getAllocatedType(), llvm::AllocaInst::getArraySize(), llvm::Module::getDataLayout(), llvm::IRBuilderBase::getInt8Ty(), llvm::Instruction::getModule(), llvm::DataLayout::getTypeAllocSize(), llvm::ConstantInt::getZExtValue(), llvm::AllocaInst::isArrayAllocation(), llvm::Align::None(), Size, and llvm::Tag.
Referenced by GetCtorAndDtorPriority(), GlobalWasGeneratedByCompiler(), and RetagMask().
|
static |
Definition at line 561 of file HWAddressSanitizer.cpp.
References llvm::report_fatal_error(), and SI.
Referenced by TypeSizeToSizeIndex().
| INITIALIZE_PASS_BEGIN | ( | HWAddressSanitizerLegacyPass | , |
| "hwasan" | , | ||
| "HWAddressSanitizer: detect memory bugs using tagged addressing." | , | ||
| false | , | ||
| false | |||
| ) |
Definition at line 805 of file HWAddressSanitizer.cpp.
References llvm::Triple::aarch64, llvm::alignTo(), llvm::appendToCompilerUsed(), llvm::AMDGPU::HSAMD::Kernel::Key::Args, assert(), llvm::BasicBlock::begin(), llvm::MCID::Bitcast, ClGenerateTagsWithCalls, ClInstrumentStack, ClRecordStackHistory, ClUARRetagToZero, llvm::GlobalVariable::copyAttributesFrom(), llvm::GlobalAlias::create(), llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateAShr(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateConstGEP1_32(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateOr(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::IRBuilder< T, Inserter >::CreatePtrToInt(), llvm::IRBuilder< T, Inserter >::CreateShl(), llvm::IRBuilder< T, Inserter >::CreateStore(), llvm::IRBuilder< T, Inserter >::CreateXor(), llvm::IRBuilder< T, Inserter >::CreateZExt(), llvm::dbgs(), llvm::dwarf::DW_OP_LLVM_tag_offset, llvm::SmallVectorBase::empty(), llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::empty(), llvm::BasicBlock::end(), llvm::GlobalVariable::eraseFromParent(), llvm::GlobalValue::ExternalLinkage, F(), llvm::ConstantInt::get(), llvm::MetadataAsValue::get(), llvm::StructType::get(), llvm::ValueAsMetadata::get(), llvm::ArrayType::get(), llvm::LocalAsMetadata::get(), llvm::MDString::get(), llvm::ConstantDataArray::get(), llvm::MDNode::get(), llvm::ConstantExpr::getAdd(), llvm::GlobalValue::getAddressSpace(), llvm::PointerType::getAddressSpace(), llvm::GlobalObject::getAlignment(), llvm::AllocaInst::getAlignment(), llvm::DataLayout::getAllocaAddrSpace(), getAllocaSizeInBytes(), llvm::AllocaInst::getAllocatedType(), llvm::ConstantStruct::getAnon(), llvm::Triple::getArch(), llvm::AllocaInst::getArraySize(), llvm::Module::getDataLayout(), llvm::Intrinsic::getDeclaration(), llvm::GlobalVariable::getInitializer(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::getInt32Ty(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::IRBuilderBase::getInt8Ty(), llvm::ConstantExpr::getIntToPtr(), llvm::GlobalValue::getLinkage(), llvm::Value::getName(), llvm::ilist_node_with_parent< NodeTy, ParentTy, Options >::getNextNode(), llvm::Constant::getNullValue(), llvm::Module::getOrInsertComdat(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), llvm::Type::getPointerTo(), llvm::ConstantExpr::getPtrToInt(), llvm::ConstantExpr::getSub(), llvm::ConstantExpr::getTrunc(), llvm::AllocaInst::getType(), llvm::Value::getType(), llvm::GlobalValue::getType(), llvm::DataLayout::getTypeAllocSize(), llvm::Use::getUser(), llvm::GlobalValue::getValueType(), llvm::GlobalValue::getVisibility(), llvm::Function::hasFnAttribute(), llvm::Value::hasName(), llvm::ARM_PROC::IE, llvm::Triple::isAArch64(), llvm::isAllocaPromotable(), llvm::Triple::isAndroid(), llvm::AllocaInst::isArrayAllocation(), llvm::GlobalVariable::isConstant(), llvm::Type::isSized(), llvm::AllocaInst::isStaticAlloca(), llvm::AllocaInst::isSwiftError(), llvm::AllocaInst::isUsedWithInAlloca(), llvm::itostr(), kHwasanPersonalityThunkName, kPointerTagShift, LLVM_DEBUG, llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::lookup(), llvm::max(), llvm::Instruction::moveBefore(), N, Name, llvm::GlobalValue::None, P, llvm::DIExpression::prependOpcodes(), llvm::GlobalValue::PrivateLinkage, llvm::SmallVectorTemplateBase< T >::push_back(), llvm::Value::replaceAllUsesWith(), llvm::Value::replaceUsesWithIf(), llvm::AllocaInst::setAlignment(), llvm::IRBuilderBase::SetInsertPoint(), llvm::Value::setName(), llvm::GlobalValue::setVisibility(), llvm::SmallVectorBase::size(), llvm::StringRef::str(), llvm::Tag, llvm::Value::takeName(), and llvm::Triple::x86_64.
|
static |
Definition at line 574 of file HWAddressSanitizer.cpp.
References llvm::Triple::aarch64, llvm::Triple::aarch64_be, llvm::HexStyle::Asm, assert(), ClInlineAllChecks, ClInstrumentMemIntrinsics, ClInstrumentWithCalls, ClMatchAllTag, llvm::countTrailingZeros(), llvm::IRBuilder< T, Inserter >::CreateAdd(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::MDBuilder::createBranchWeights(), llvm::IRBuilder< T, Inserter >::CreateCall(), llvm::IRBuilder< T, Inserter >::CreateGEP(), llvm::IRBuilder< T, Inserter >::CreateICmpNE(), llvm::IRBuilder< T, Inserter >::CreateICmpUGE(), llvm::IRBuilder< T, Inserter >::CreateICmpUGT(), llvm::IRBuilder< T, Inserter >::CreateIntCast(), llvm::IRBuilder< T, Inserter >::CreateIntToPtr(), llvm::IRBuilder< T, Inserter >::CreateLoad(), llvm::IRBuilder< T, Inserter >::CreateLShr(), llvm::IRBuilder< T, Inserter >::CreateOr(), llvm::IRBuilder< T, Inserter >::CreatePointerCast(), llvm::IRBuilder< T, Inserter >::CreateTrunc(), llvm::dbgs(), llvm::Instruction::eraseFromParent(), llvm::InlineAsm::get(), llvm::ConstantInt::get(), llvm::FunctionType::get(), llvm::Triple::getArch(), llvm::Intrinsic::getDeclaration(), llvm::IRBuilderBase::GetInsertBlock(), llvm::IRBuilderBase::getInt32Ty(), llvm::IRBuilderBase::getInt8PtrTy(), llvm::IRBuilderBase::getInt8Ty(), llvm::ConstantExpr::getIntToPtr(), llvm::User::getOperand(), llvm::Instruction::getParent(), llvm::BasicBlock::getParent(), llvm::GlobalValue::getParent(), getPointerOperandIndex(), llvm::Value::getType(), llvm::IRBuilderBase::getVoidTy(), llvm::Triple::isAArch64(), llvm::Triple::isOSBinFormatELF(), llvm::isPowerOf2_64(), llvm::itostr(), kNumberOfAccessSizes, LLVM_DEBUG, MI, llvm::report_fatal_error(), llvm::IRBuilderBase::SetInsertPoint(), llvm::User::setOperand(), llvm::SplitBlockAndInsertIfThen(), and llvm::Triple::x86_64.
| HWAddressSanitizer __pad0__ |
Definition at line 336 of file HWAddressSanitizer.cpp.
|
static |
|
static |
Referenced by RetagMask().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
Referenced by TypeSizeToSizeIndex().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
Referenced by TypeSizeToSizeIndex().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
Referenced by RetagMask().
|
static |
Referenced by getAllocaSizeInBytes(), and TypeSizeToSizeIndex().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
|
static |
Referenced by TypeSizeToSizeIndex().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
Referenced by RetagMask().
|
static |
|
static |
Referenced by RetagMask().
|
static |
Referenced by llvm::HWAddressSanitizerPass::run().
|
static |
|
static |
| HWAddressSanitizer false |
Definition at line 336 of file HWAddressSanitizer.cpp.
| hwasan |
Definition at line 336 of file HWAddressSanitizer.cpp.
|
static |
Definition at line 69 of file HWAddressSanitizer.cpp.
|
static |
Definition at line 70 of file HWAddressSanitizer.cpp.
Referenced by llvm::HWAddressSanitizerPass::run().
Definition at line 59 of file HWAddressSanitizer.cpp.
Definition at line 57 of file HWAddressSanitizer.cpp.
Definition at line 58 of file HWAddressSanitizer.cpp.
Definition at line 60 of file HWAddressSanitizer.cpp.
Referenced by RetagMask().
Definition at line 63 of file HWAddressSanitizer.cpp.
|
static |
Definition at line 67 of file HWAddressSanitizer.cpp.
Referenced by llvm::HWAddressSanitizerPass::run(), and TypeSizeToSizeIndex().
Definition at line 72 of file HWAddressSanitizer.cpp.
Referenced by RetagMask().
Definition at line 74 of file HWAddressSanitizer.cpp.
1.8.13