[PATCH] D33267: [lld] Write the correct age and machine type to the PDB.

Zachary Turner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 21:41:03 PDT 2017


zturner created this revision.

The age has to be written in two places and the two values have to agree with each other.  Prior to this change, when I ran `llvm-pdbdump raw -all` on a PDB generated with lld it would error out.  This patch fixes that.  Now when I link two trivial object files with LLD and dump the resulting PDB, I get actual data.  So far it only prints the section contents, but I'll look into getting symbol and type information in next.


https://reviews.llvm.org/D33267

Files:
  lld/COFF/PDB.cpp


Index: lld/COFF/PDB.cpp
===================================================================
--- lld/COFF/PDB.cpp
+++ lld/COFF/PDB.cpp
@@ -188,7 +188,8 @@
 
   // Add an Info stream.
   auto &InfoBuilder = Builder.getInfoBuilder();
-  InfoBuilder.setAge(DI ? DI->PDB70.Age : 0);
+  uint32_t Age = DI ? DI->PDB70.Age : 0;
+  InfoBuilder.setAge(Age);
 
   pdb::PDB_UniqueId uuid{};
   if (DI)
@@ -201,6 +202,11 @@
   // Add an empty DPI stream.
   auto &DbiBuilder = Builder.getDbiBuilder();
   DbiBuilder.setVersionHeader(pdb::PdbDbiV110);
+  DbiBuilder.setAge(Age);
+  if (!Symtab->ObjectFiles.empty()) {
+    auto M = Symtab->ObjectFiles.front()->getMachineType();
+    DbiBuilder.setMachineType(static_cast<pdb::PDB_Machine>(M));
+  }
 
   codeview::TypeTableBuilder TypeTable(BAlloc);
   codeview::TypeTableBuilder IDTable(BAlloc);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33267.99242.patch
Type: text/x-patch
Size: 834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170517/b4c49304/attachment.bin>


More information about the llvm-commits mailing list