summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
diff options
context:
space:
mode:
authorMitch Phillips <mitchphillips@outlook.com>2017-11-10 21:00:22 +0000
committerMitch Phillips <mitchphillips@outlook.com>2017-11-10 21:00:22 +0000
commit3b9ea32ef83247090205891af305d98a3aa5c975 (patch)
treedb95d9de57ea5c37668ac3abb87d181a56b10b7c /llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
parent3f0f650f498d97516745678b304a1649c3b2450f (diff)
downloadbcm5719-llvm-3b9ea32ef83247090205891af305d98a3aa5c975.tar.gz
bcm5719-llvm-3b9ea32ef83247090205891af305d98a3aa5c975.zip
[cfi-verify] Made FileAnalysis operate on a GraphResult rather than build one and validate it.
Refactors the behaviour of building graphs out of FileAnalysis, allowing for analysis of the GraphResult by the callee without having to rebuild the graph. Means when we want to analyse the constructed graph (planned for later revisions), we don't do repeated work. Also makes CFI verification in FileAnalysis now return an enum that allows us to differentiate why something failed, not just that it did/didn't fail. Reviewers: vlad.tsyrklevich Subscribers: kcc, pcc, llvm-commits Differential Revision: https://reviews.llvm.org/D39764 llvm-svn: 317927
Diffstat (limited to 'llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h')
-rw-r--r--llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h43
1 files changed, 26 insertions, 17 deletions
diff --git a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
index e0eecb037c3..dfeff13863b 100644
--- a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
+++ b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.h
@@ -44,8 +44,29 @@
namespace llvm {
namespace cfi_verify {
+struct GraphResult;
+
extern bool IgnoreDWARFFlag;
+enum class CFIProtectionStatus {
+ // This instruction is protected by CFI.
+ PROTECTED,
+ // The instruction is not an indirect control flow instruction, and thus
+ // shouldn't be protected.
+ FAIL_NOT_INDIRECT_CF,
+ // There is a path to the instruction that was unexpected.
+ FAIL_ORPHANS,
+ // There is a path to the instruction from a conditional branch that does not
+ // properly check the destination for this vcall/icall.
+ FAIL_BAD_CONDITIONAL_BRANCH,
+ // The instruction referenced does not exist. This normally indicates an
+ // error in the program, where you try and validate a graph that was created
+ // in a different FileAnalysis object.
+ FAIL_INVALID_INSTRUCTION,
+};
+
+StringRef stringCFIProtectionStatus(CFIProtectionStatus Status);
+
// Disassembler and analysis tool for machine code files. Keeps track of non-
// sequential control flows, including indirect control flow instructions.
class FileAnalysis {
@@ -69,12 +90,6 @@ public:
FileAnalysis(const FileAnalysis &) = delete;
FileAnalysis(FileAnalysis &&Other) = default;
- // Check whether the provided instruction is CFI protected in this file.
- // Returns false if this instruction doesn't exist in this file, if it's not
- // an indirect control flow instruction, or isn't CFI protected. Returns true
- // otherwise.
- bool isIndirectInstructionCFIProtected(uint64_t Address) const;
-
// Returns the instruction at the provided address. Returns nullptr if there
// is no instruction at the provided address.
const Instr *getInstruction(uint64_t Address) const;
@@ -122,19 +137,13 @@ public:
const MCRegisterInfo *getRegisterInfo() const;
const MCInstrInfo *getMCInstrInfo() const;
const MCInstrAnalysis *getMCInstrAnalysis() const;
- symbolize::LLVMSymbolizer &getSymbolizer();
-
- // Returns true if this class is using DWARF line tables for elimination.
- bool hasLineTableInfo() const;
- // Returns the line table information for the range {Address +-
- // DWARFSearchRange}. Returns an empty table if the address has no valid line
- // table information, or this analysis object has DWARF handling disabled.
- DILineInfoTable getLineInfoForAddressRange(uint64_t Address);
+ // Returns the inlining information for the provided address.
+ Expected<DIInliningInfo> symbolizeInlinedCode(uint64_t Address);
- // Returns whether the provided address has valid line information for
- // instructions in the range of Address +- DWARFSearchRange.
- bool hasValidLineInfoForAddressRange(uint64_t Address);
+ // Returns whether the provided Graph represents a protected indirect control
+ // flow instruction in this file.
+ CFIProtectionStatus validateCFIProtection(const GraphResult &Graph) const;
protected:
// Construct a blank object with the provided triple and features. Used in
OpenPOWER on IntegriCloud