diff options
| author | Mitch Phillips <mitchphillips@outlook.com> | 2017-11-09 00:18:31 +0000 |
|---|---|---|
| committer | Mitch Phillips <mitchphillips@outlook.com> | 2017-11-09 00:18:31 +0000 |
| commit | d64af525853ebe92cc794f3abd1f820591add786 (patch) | |
| tree | e5053e32ad7d08ec3b38a3e7ba97a71a2f80922f /llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp | |
| parent | fb5ef73460189fa410e2b42fba827d131142ca0e (diff) | |
| download | bcm5719-llvm-d64af525853ebe92cc794f3abd1f820591add786.tar.gz bcm5719-llvm-d64af525853ebe92cc794f3abd1f820591add786.zip | |
[cfi-verify] Adds blacklist blame behaviour to cfi-verify.
Adds the blacklist behaviour to llvm-cfi-verify. Now will calculate which lines caused expected failures in the blacklist and reports the number of affected indirect CF instructions for each blacklist entry.
Also moved DWARF checking after instruction analysis to improve performance significantly - unrolling the inlining stack is expensive.
Reviewers: vlad.tsyrklevich
Subscribers: aprantl, pcc, kcc, llvm-commits
Differential Revision: https://reviews.llvm.org/D39750
llvm-svn: 317743
Diffstat (limited to 'llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp')
| -rw-r--r-- | llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp b/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp index 3b4a5c155d0..01f03158d6b 100644 --- a/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp +++ b/llvm/tools/llvm-cfi-verify/llvm-cfi-verify.cpp @@ -47,6 +47,7 @@ void printIndirectCFInstructions(FileAnalysis &Analysis, uint64_t UnexpectedUnprotected = 0; symbolize::LLVMSymbolizer &Symbolizer = Analysis.getSymbolizer(); + std::map<unsigned, uint64_t> BlameCounter; for (uint64_t Address : Analysis.getIndirectInstructions()) { const auto &InstrMeta = Analysis.getInstructionOrDie(Address); @@ -97,20 +98,20 @@ void printIndirectCFInstructions(FileAnalysis &Analysis, continue; } - bool MatchesBlacklistRule = false; - if (SpecialCaseList->inSection("cfi-icall", "src", LineInfo.FileName) || - SpecialCaseList->inSection("cfi-vcall", "src", LineInfo.FileName)) { - outs() << "BLACKLIST MATCH, 'src'\n"; - MatchesBlacklistRule = true; + unsigned BlameLine = 0; + for (auto &K : {"cfi-icall", "cfi-vcall"}) { + if (!BlameLine) + BlameLine = + SpecialCaseList->inSectionBlame(K, "src", LineInfo.FileName); + if (!BlameLine) + BlameLine = + SpecialCaseList->inSectionBlame(K, "fun", LineInfo.FunctionName); } - if (SpecialCaseList->inSection("cfi-icall", "fun", LineInfo.FunctionName) || - SpecialCaseList->inSection("cfi-vcall", "fun", LineInfo.FunctionName)) { - outs() << "BLACKLIST MATCH, 'fun'\n"; - MatchesBlacklistRule = true; - } - - if (MatchesBlacklistRule) { + if (BlameLine) { + outs() << "Blacklist Match: " << BlacklistFilename << ":" << BlameLine + << "\n"; + BlameCounter[BlameLine]++; if (CFIProtected) { UnexpectedProtected++; outs() << "====> Unexpected Protected\n"; @@ -149,6 +150,15 @@ void printIndirectCFInstructions(FileAnalysis &Analysis, ((double)ExpectedUnprotected) / IndirectCFInstructions, UnexpectedUnprotected, ((double)UnexpectedUnprotected) / IndirectCFInstructions); + + if (!SpecialCaseList) + return; + + outs() << "Blacklist Results:\n"; + for (const auto &KV : BlameCounter) { + outs() << " " << BlacklistFilename << ":" << KV.first << " affects " + << KV.second << " indirect CF instructions.\n"; + } } int main(int argc, char **argv) { |

