diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2017-07-06 17:56:01 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2017-07-06 17:56:01 +0000 |
commit | 67a3f7fd42985d53016092c5f94670e2fe9a3381 (patch) | |
tree | be66c2e37edf4c5d0b6c39d5fec84f590d8cddd2 /tools/llvm-bcanalyzer | |
parent | a5a5f8ef6fce7362a52b5b6917c15b5250693ac9 (diff) |
Bitcode: Include any strings added to the string table in the module hash.
Differential Revision: https://reviews.llvm.org/D35037
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307286 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-bcanalyzer')
-rw-r--r-- | tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index 528247c2dbc3..529bdf5b7d93 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -71,6 +71,10 @@ static cl::opt<bool> ShowBinaryBlobs("show-binary-blobs", cl::desc("Print binary blobs using hex escapes")); +static cl::opt<std::string> CheckHash( + "check-hash", + cl::desc("Check module hash using the argument as a string table")); + namespace { /// CurStreamTypeType - A type for CurStreamType @@ -652,13 +656,15 @@ static bool ParseBlock(BitstreamCursor &Stream, BitstreamBlockInfo &BlockInfo, } // If we found a module hash, let's verify that it matches! - if (BlockID == bitc::MODULE_BLOCK_ID && Code == bitc::MODULE_CODE_HASH) { + if (BlockID == bitc::MODULE_BLOCK_ID && Code == bitc::MODULE_CODE_HASH && + !CheckHash.empty()) { if (Record.size() != 5) outs() << " (invalid)"; else { // Recompute the hash and compare it to the one in the bitcode SHA1 Hasher; StringRef Hash; + Hasher.update(CheckHash); { int BlockSize = (CurrentRecordPos / 8) - BlockEntryPos; auto Ptr = Stream.getPointerToByte(BlockEntryPos, BlockSize); |