summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-07-07 20:25:39 +0000
committerZachary Turner <zturner@google.com>2017-07-07 20:25:39 +0000
commit3a11fdf8ce5099db375c0f0f2c210818013429a5 (patch)
treecc043bf6f33b39b86ecc678beeed57406c39c23e
parente3872003d0129dcb8324e7025012e4201bf364f4 (diff)
downloadbcm5719-llvm-3a11fdf8ce5099db375c0f0f2c210818013429a5.tar.gz
bcm5719-llvm-3a11fdf8ce5099db375c0f0f2c210818013429a5.zip
[PDB] More changes to bring lld PDBs to parity with MSVC.
1) Don't write a /src/headerblock stream. This appears to be written conditionally by MSVC, but it's not clear what the condition is. For now, just remove it since we dont' know what it is anyway and the particular pdb we've checked in for the test doesn't have one. 2) Write a valid timestamp for the PDB file signature. This leads to non-reproducible builds, but it matches the default behavior of link, so it should be out default as well. If we need reproducibility, we should add a separate command line option for it that is off by default. 3) Write an empty FPO stream. MSVC seems to always write an FPO stream. This change makes the stream directory match up, although we still need to make the contents of the FPO stream match. llvm-svn: 307436
-rw-r--r--lld/COFF/PDB.cpp5
-rw-r--r--lld/test/COFF/pdb-diff.test18
-rw-r--r--lld/test/COFF/pdb-none.test4
-rw-r--r--lld/test/COFF/pdb.test12
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp6
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp2
6 files changed, 21 insertions, 26 deletions
diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 02cb1f51e3d..d34e3f06d5b 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -412,7 +412,6 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab,
// Add an Info stream.
auto &InfoBuilder = Builder.getInfoBuilder();
InfoBuilder.setAge(DI ? DI->PDB70.Age : 0);
- InfoBuilder.setSignature(time(nullptr));
llvm::SmallString<128> NativePath(Path.begin(), Path.end());
llvm::sys::fs::make_absolute(NativePath);
@@ -422,13 +421,13 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab,
if (DI)
memcpy(&uuid, &DI->PDB70.Signature, sizeof(uuid));
InfoBuilder.setGuid(uuid);
- // Should be the current time, but set 0 for reproducibilty.
- InfoBuilder.setSignature(0);
+ InfoBuilder.setSignature(time(nullptr));
InfoBuilder.setVersion(pdb::PdbRaw_ImplVer::PdbImplVC70);
// Add an empty DBI stream.
pdb::DbiStreamBuilder &DbiBuilder = Builder.getDbiBuilder();
DbiBuilder.setVersionHeader(pdb::PdbDbiV70);
+ ExitOnErr(DbiBuilder.addDbgStream(pdb::DbgHeaderType::NewFPO, {}));
// It's not entirely clear what this is, but the * Linker * module uses it.
uint32_t PdbFilePathNI = DbiBuilder.addECName(NativePath);
diff --git a/lld/test/COFF/pdb-diff.test b/lld/test/COFF/pdb-diff.test
index 0a353a36891..9c9892b5bba 100644
--- a/lld/test/COFF/pdb-diff.test
+++ b/lld/test/COFF/pdb-diff.test
@@ -37,14 +37,14 @@ CHECK-NEXT: | DBI Stream | I |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | IPI Stream | I |
CHECK-NEXT: |------------------------------+---|
+CHECK-NEXT: | New FPO Data | {{[EI]}} |
+CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Section Header Data | {{[EI]}} |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Named Stream "/names" | {{[EI]}} |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Named Stream "/LinkInfo" | {{[EI]}} |
CHECK-NEXT: |------------------------------+---|
-CHECK-NEXT: | Named Stream "/src/heade..." | D |
-CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Module "{{.*}}\pdb-diff.obj" | {{[EI]}} |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Module "* Linker *" | {{[EI]}} |
@@ -59,8 +59,6 @@ CHECK-NEXT: | Public Symbol Hash | D |
CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: | Public Symbol Records | D |
CHECK-NEXT: |------------------------------+---|
-CHECK-NEXT: | New FPO Data | D |
-CHECK-NEXT: |------------------------------+---|
CHECK-NEXT: ------------------------------------
CHECK-NEXT: | String Table |
CHECK-NEXT: |------------------------------+---|
@@ -101,15 +99,13 @@ CHECK-NEXT: | Features (set) | I |
CHECK-NEXT: |----------------------+---|
CHECK-NEXT: | Feature | I |
CHECK-NEXT: |----------------------+---|
-CHECK-NEXT: | Named Stream Size | D |
-CHECK-NEXT: |----------------------+---|
-CHECK-NEXT: | Named Streams (map) | D |
+CHECK-NEXT: | Named Stream Size |
CHECK-NEXT: |----------------------+---|
-CHECK-NEXT: | /names | I |
+CHECK-NEXT: | Named Streams (map) | {{[EI]}} |
CHECK-NEXT: |----------------------+---|
-CHECK-NEXT: | /LinkInfo | E |
+CHECK-NEXT: | /names | {{[EI]}} |
CHECK-NEXT: |----------------------+---|
-CHECK-NEXT: | /src/headerblock | D |
+CHECK-NEXT: | /LinkInfo | {{[EI]}} |
CHECK-NEXT: |----------------------+---|
CHECK-NEXT: ----------------------------------------------
CHECK-NEXT: | DBI Stream |
@@ -152,7 +148,7 @@ CHECK-NEXT: | DBG (Xdata) | I |
CHECK-NEXT: |----------------------------------------+---|
CHECK-NEXT: | DBG (Pdata) | I |
CHECK-NEXT: |----------------------------------------+---|
-CHECK-NEXT: | DBG (NewFPO) | D |
+CHECK-NEXT: | DBG (NewFPO) | {{[EI]}} |
CHECK-NEXT: |----------------------------------------+---|
CHECK-NEXT: | DBG (SectionHdrOrig) | I |
CHECK-NEXT: |----------------------------------------+---|
diff --git a/lld/test/COFF/pdb-none.test b/lld/test/COFF/pdb-none.test
index a028cf05547..c1becbad7a3 100644
--- a/lld/test/COFF/pdb-none.test
+++ b/lld/test/COFF/pdb-none.test
@@ -7,8 +7,8 @@
# CHECK: PdbStream:
# CHECK-NEXT: Age: 0
-# CHECK-NEXT: Guid: '{00000000-0000-0000-0000-000000000000}'
-# CHECK-NEXT: Signature: 0
+# CHECK-NEXT: Guid:
+# CHECK-NEXT: Signature:
# CHECK-NEXT: Features: [ VC140 ]
# CHECK-NEXT: Version: VC70
diff --git a/lld/test/COFF/pdb.test b/lld/test/COFF/pdb.test
index 5ad6fcebf41..a4cd4f7c35b 100644
--- a/lld/test/COFF/pdb.test
+++ b/lld/test/COFF/pdb.test
@@ -26,7 +26,7 @@
# CHECK: PdbStream:
# CHECK-NEXT: Age: 1
# CHECK-NEXT: Guid:
-# CHECK-NEXT: Signature: 0
+# CHECK-NEXT: Signature:
# CHECK-NEXT: Features: [ VC140 ]
# CHECK-NEXT: Version: VC70
# CHECK-NEXT: DbiStream:
@@ -186,17 +186,17 @@ RAW-NEXT: IMAGE_SCN_MEM_READ
RAW: Section Map
RAW-NEXT: ============================================================
RAW-NEXT: Section 0000 | ovl = 0, group = 0, frame = 0, name = 1
-RAW-NEXT: class = 65535, offset = 0, size =
+RAW-NEXT: class = 65535, offset = 0, size =
RAW-NEXT: flags = read | 32 bit addr | selector
RAW-NEXT: Section 0001 | ovl = 1, group = 0, frame = 0, name = 2
-RAW-NEXT: class = 65535, offset = 0, size =
+RAW-NEXT: class = 65535, offset = 0, size =
RAW-NEXT: flags = read | execute | 32 bit addr | selector
RAW-NEXT: Section 0002 | ovl = 2, group = 0, frame = 0, name = 3
-RAW-NEXT: class = 65535, offset = 0, size =
+RAW-NEXT: class = 65535, offset = 0, size =
RAW-NEXT: flags = read | 32 bit addr | selector
RAW-NEXT: Section 0003 | ovl = 3, group = 0, frame = 0, name = 4
-RAW-NEXT: class = 65535, offset = 0, size =
+RAW-NEXT: class = 65535, offset = 0, size =
RAW-NEXT: flags = read | 32 bit addr | selector
RAW-NEXT: Section 0004 | ovl = 4, group = 0, frame = 0, name = 5
-RAW-NEXT: class = 65535, offset = 0, size =
+RAW-NEXT: class = 65535, offset = 0, size =
RAW-NEXT: flags = 32 bit addr | absolute addr
diff --git a/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp b/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
index 354b8c0e07f..6cdf6dde04d 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NamedStreamMap.cpp
@@ -86,7 +86,8 @@ Error NamedStreamMap::commit(BinaryStreamWriter &Writer) const {
for (const auto &Name : OrderedStreamNames) {
auto Item = Mapping.find(Name);
- assert(Item != Mapping.end());
+ if (Item == Mapping.end())
+ continue;
if (auto EC = Writer.writeCString(Item->getKey()))
return EC;
}
@@ -108,7 +109,8 @@ uint32_t NamedStreamMap::finalize() {
for (const auto &Name : OrderedStreamNames) {
auto Item = Mapping.find(Name);
- assert(Item != Mapping.end());
+ if (Item == Mapping.end())
+ continue;
FinalizedHashTable.set(FinalizedInfo->StringDataBytes, Item->getValue());
FinalizedInfo->StringDataBytes += Item->getKeyLength() + 1;
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
index 12b0c3b36c1..e8ec96ecafe 100644
--- a/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/PDBFileBuilder.cpp
@@ -96,8 +96,6 @@ Expected<msf::MSFLayout> PDBFileBuilder::finalizeMsfLayout() {
return std::move(EC);
if (auto EC = addNamedStream("/LinkInfo", 0))
return std::move(EC);
- if (auto EC = addNamedStream("/src/headerblock", 0))
- return std::move(EC);
if (Info) {
if (auto EC = Info->finalizeMsfLayout())
OpenPOWER on IntegriCloud