diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-10-09 09:06:30 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-10-09 09:06:30 +0000 |
commit | 02184ba995f85cf50e5ff1457c9aeebe53a20b41 (patch) | |
tree | 109e49ffdfe7d973dd9a2f38b0658fb1e0cb188f /source | |
parent | 2907abe4dea438c4758377f8f7cdbbc06f97cce2 (diff) | |
download | lldb-02184ba995f85cf50e5ff1457c9aeebe53a20b41.tar.gz |
Unify the two CRC implementations
David added the JamCRC implementation in r246590. More recently, Eugene
added a CRC-32 implementation in r357901, which falls back to zlib's
crc32 function if present.
These checksums are essentially the same, so having multiple
implementations seems unnecessary. This replaces the CRC-32
implementation with the simpler one from JamCRC, and implements the
JamCRC interface in terms of CRC-32 since this means it can use zlib's
implementation when available, saving a few bytes and potentially making
it faster.
JamCRC took an ArrayRef<char> argument, and CRC-32 took a StringRef.
This patch changes it to ArrayRef<uint8_t> which I think is the best
choice, and simplifies a few of the callers nicely.
Differential revision: https://reviews.llvm.org/D68570
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@374148 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'source')
-rw-r--r-- | source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp index c3a99cf69..a52f774e4 100644 --- a/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ b/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -36,7 +36,7 @@ #include "llvm/BinaryFormat/ELF.h" #include "llvm/Object/Decompressor.h" #include "llvm/Support/ARMBuildAttributes.h" -#include "llvm/Support/JamCRC.h" +#include "llvm/Support/CRC.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MipsABIFlags.h" @@ -398,10 +398,8 @@ bool ObjectFileELF::MagicBytesMatch(DataBufferSP &data_sp, } static uint32_t calc_crc32(uint32_t init, const DataExtractor &data) { - llvm::JamCRC crc(~init); - crc.update(llvm::makeArrayRef( - reinterpret_cast<const char *>(data.GetDataStart()), data.GetByteSize())); - return ~crc.getCRC(); + return llvm::crc32( + init, llvm::makeArrayRef(data.GetDataStart(), data.GetByteSize())); } uint32_t ObjectFileELF::CalculateELFNotesSegmentsCRC32( |