[PATCH] D45276: Fix a couple of incorrect fields in our generated PDBs.
Zachary Turner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 4 11:34:14 PDT 2018
zturner created this revision.
zturner added a reviewer: rnk.
Herald added a subscriber: hiraditya.
Most of these are pretty trivial and obvious. Setting the toolchain version to 14.11 is perhaps a little questionable, but we've been bitten in the past where one of our version fields sidn't match MSVC's, and I definitely don't want to go through that diagnosis again as it was pretty time consuming and hard to track down.
I found all of these by using `llvm-pdbutil export` to dump the dbi and pdb streams to a file, then using `fc` followed by `llvm-pdbutil explain` to explain the mismatched bytes.
There are still some more, these are just the low hanging fruit.
https://reviews.llvm.org/D45276
Files:
lld/COFF/PDB.cpp
llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
Index: llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
===================================================================
--- llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
+++ llvm/lib/DebugInfo/PDB/Native/DbiStreamBuilder.cpp
@@ -37,6 +37,14 @@
void DbiStreamBuilder::setBuildNumber(uint16_t B) { BuildNumber = B; }
+void DbiStreamBuilder::setBuildNumber(uint8_t Major, uint8_t Minor) {
+ BuildNumber = (uint16_t(Major) << DbiBuildNo::BuildMajorShift) &
+ DbiBuildNo::BuildMajorMask;
+ BuildNumber |= (uint16_t(Minor) << DbiBuildNo::BuildMinorShift) &
+ DbiBuildNo::BuildMinorMask;
+ BuildNumber |= DbiBuildNo::NewVersionFormatMask;
+}
+
void DbiStreamBuilder::setPdbDllVersion(uint16_t V) { PdbDllVersion = V; }
void DbiStreamBuilder::setPdbDllRbld(uint16_t R) { PdbDllRbld = R; }
@@ -251,7 +259,7 @@
H->TypeServerSize = 0;
H->SymRecordStreamIndex = SymRecordStreamIndex;
H->PublicSymbolStreamIndex = PublicsStreamIndex;
- H->MFCTypeServerIndex = kInvalidStreamIndex;
+ H->MFCTypeServerIndex = 0; // Not sure what this is, but link.exe writes 0.
H->GlobalSymbolStreamIndex = GlobalsStreamIndex;
Header = H;
Index: llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
===================================================================
--- llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
+++ llvm/include/llvm/DebugInfo/PDB/Native/DbiStreamBuilder.h
@@ -46,6 +46,7 @@
void setVersionHeader(PdbRaw_DbiVer V);
void setAge(uint32_t A);
void setBuildNumber(uint16_t B);
+ void setBuildNumber(uint8_t Major, uint8_t Minor);
void setPdbDllVersion(uint16_t V);
void setPdbDllRbld(uint16_t R);
void setFlags(uint16_t F);
Index: lld/COFF/PDB.cpp
===================================================================
--- lld/COFF/PDB.cpp
+++ lld/COFF/PDB.cpp
@@ -1088,6 +1088,13 @@
pdb::DbiStreamBuilder &DbiBuilder = Builder.getDbiBuilder();
DbiBuilder.setAge(BuildId.PDB70.Age);
DbiBuilder.setVersionHeader(pdb::PdbDbiV70);
+ DbiBuilder.setMachineType(Config->is64() ? pdb::PDB_Machine::Amd64
+ : pdb::PDB_Machine::x86);
+ // Technically we are not link.exe 14.11, but there are known cases where
+ // debugging tools on Windows expect Microsoft-specific version numbers or
+ // they fail to work at all. Since we know we produce PDBs that are
+ // compatible with LINK 14.11, we set that version number here.
+ DbiBuilder.setBuildNumber(14, 11);
}
void PDBLinker::addSectionContrib(pdb::DbiModuleDescriptorBuilder &LinkerModule,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45276.141008.patch
Type: text/x-patch
Size: 2588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180404/73ecd7dc/attachment.bin>
More information about the llvm-commits
mailing list