mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-04 08:27:50 +00:00
Switch PTH format from a 7 byte magic number to an 8 byte one, to avoid
misaligned reads throughout the file. Bump PTH format version to 10. llvm-svn: 162076
This commit is contained in:
parent
2fe6aab788
commit
2683b4c0fd
@ -101,7 +101,7 @@ class PTHManager : public IdentifierInfoLookup {
|
||||
|
||||
public:
|
||||
// The current PTH version.
|
||||
enum { Version = 9 };
|
||||
enum { Version = 10 };
|
||||
|
||||
~PTHManager();
|
||||
|
||||
|
@ -447,7 +447,7 @@ Offset PTHWriter::EmitCachedSpellings() {
|
||||
|
||||
void PTHWriter::GeneratePTH(const std::string &MainFile) {
|
||||
// Generate the prologue.
|
||||
Out << "cfe-pth";
|
||||
Out << "cfe-pth" << '\0';
|
||||
Emit32(PTHManager::Version);
|
||||
|
||||
// Leave 4 words for the prologue.
|
||||
|
@ -452,14 +452,14 @@ PTHManager *PTHManager::Create(const std::string &file,
|
||||
const unsigned char *BufEnd = (unsigned char*)File->getBufferEnd();
|
||||
|
||||
// Check the prologue of the file.
|
||||
if ((BufEnd - BufBeg) < (signed)(sizeof("cfe-pth") + 3 + 4) ||
|
||||
memcmp(BufBeg, "cfe-pth", sizeof("cfe-pth") - 1) != 0) {
|
||||
if ((BufEnd - BufBeg) < (signed)(sizeof("cfe-pth") + 4 + 4) ||
|
||||
memcmp(BufBeg, "cfe-pth", sizeof("cfe-pth")) != 0) {
|
||||
Diags.Report(diag::err_invalid_pth_file) << file;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read the PTH version.
|
||||
const unsigned char *p = BufBeg + (sizeof("cfe-pth") - 1);
|
||||
const unsigned char *p = BufBeg + (sizeof("cfe-pth"));
|
||||
unsigned Version = ReadLE32(p);
|
||||
|
||||
if (Version < PTHManager::Version) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user