Index: COFF/PDB.cpp =================================================================== --- COFF/PDB.cpp +++ COFF/PDB.cpp @@ -85,7 +85,12 @@ public: PDBLinker(SymbolTable *Symtab) : Alloc(), Symtab(Symtab), Builder(Alloc), TypeTable(Alloc), - IDTable(Alloc), GlobalTypeTable(Alloc), GlobalIDTable(Alloc) {} + IDTable(Alloc), GlobalTypeTable(Alloc), GlobalIDTable(Alloc) { + // This isn't strictly necessary, but link.exe usually puts an empty string + // as the first "valid" string in the string table, so we do the same in + // order to maintain as much byte-for-byte compatibility as possible. + PDBStrTab.insert(""); + } /// Emit the basic PDB structure: initial streams, headers, etc. void initialize(const llvm::codeview::DebugInfo &BuildId); @@ -1066,7 +1071,6 @@ pdb::DbiStreamBuilder &DbiBuilder = Builder.getDbiBuilder(); DbiBuilder.setAge(BuildId.PDB70.Age); DbiBuilder.setVersionHeader(pdb::PdbDbiV70); - ExitOnErr(DbiBuilder.addDbgStream(pdb::DbgHeaderType::NewFPO, {})); } void PDBLinker::addSectionContrib(pdb::DbiModuleDescriptorBuilder &LinkerModule, Index: test/COFF/pdb-diff.test =================================================================== --- test/COFF/pdb-diff.test +++ test/COFF/pdb-diff.test @@ -1,215 +0,0 @@ -This test verifies that we produce PDBs compatible with MSVC in various ways. -We check in a cl-generated object file, PDB, and original source which serve -as the "baseline" for us to measure against. Then we link the same object -file with LLD and compare the two PDBs. Since the baseline object file and -PDB are already checked in, we just run LLD on the object file. - -RUN: rm -f %T/pdb-diff-lld.pdb %T/pdb-diff-lld.exe -RUN: lld-link /debug /pdb:%T/pdb-diff-lld.pdb /out:%T/pdb-diff-lld.exe /nodefaultlib \ -RUN: /entry:main %S/Inputs/pdb-diff.obj -RUN: llvm-pdbutil diff -result -values=false -left-bin-root=%S -right-bin-root=D:/src/llvm-mono/lld/test/COFF/ \ -RUN: %T/pdb-diff-lld.pdb %S/Inputs/pdb-diff-cl.pdb | FileCheck %s - -CHECK: ---------------------- -CHECK-NEXT: | MSF Super Block | -CHECK-NEXT: |----------------+---| -CHECK-NEXT: | File | | -CHECK-NEXT: |----------------+---| -CHECK-NEXT: | Block Size | I | -CHECK-NEXT: |----------------+---| -CHECK-NEXT: | Block Count | -CHECK-NEXT: |----------------+---| -CHECK-NEXT: | Unknown 1 | I | -CHECK-NEXT: |----------------+---| -CHECK-NEXT: | Directory Size | -CHECK-NEXT: |----------------+---| -CHECK-NEXT: ------------------------------------ -CHECK-NEXT: | Stream Directory | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | File | | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Stream Count | I | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Old MSF Directory | I | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | PDB Stream | I | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | TPI Stream | I | -CHECK-NEXT: |------------------------------+---| -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: | Module "Inputs\pdb-diff.obj" | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Module "* Linker *" | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | TPI Hash | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | IPI Hash | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Public Symbol Hash | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Global Symbol Hash | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Symbol Records | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: ------------------------------------ -CHECK-NEXT: | String Table | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | File | | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Number of Strings | D | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Hash Version | I | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Byte Size | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Signature | I | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Empty Strings | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | {{.*}}pdb-diff.cpp | {{[EI]}} | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | $T0 $ebp = $...p $T0 8 + = | D | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | d:\src\llvm-...er internal) | D | -CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: ---------------------------- -CHECK-NEXT: | PDB Stream | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | File | | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Stream Size | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Age | I | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Guid | D | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Signature | D | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Version | I | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Features (set) | I | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Feature | I | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Named Stream Size | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | Named Streams (map) | {{[EI]}} | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | /names | {{[EI]}} | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: | /LinkInfo | {{[EI]}} | -CHECK-NEXT: |----------------------+---| -CHECK-NEXT: ---------------------------------------------- -CHECK-NEXT: | DBI Stream | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | File | | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Dbi Version | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Age | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Machine | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Flags | D | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Build Major | D | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Build Minor | D | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Build Number | D | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | PDB DLL Version | D | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | PDB DLL RBLD | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (FPO) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (Exception) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (Fixup) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (OmapToSrc) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (OmapFromSrc) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (SectionHdr) | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (TokenRidMap) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (Xdata) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (Pdata) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (NewFPO) | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | DBG (SectionHdrOrig) | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Globals Stream | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Publics Stream | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Symbol Records | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Has CTypes | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Is Incrementally Linked | D | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Is Stripped | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Module Count | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Source File Count | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Module "Inputs\pdb-diff.obj" | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Modi | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Obj File Name | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Debug Stream | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - C11 Byte Size | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - C13 Byte Size | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - # of files | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Pdb File Path Index | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Source File Name Index | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Symbol Byte Size | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Module "* Linker *" | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Modi | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Obj File Name | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Debug Stream | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - C11 Byte Size | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - C13 Byte Size | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - # of files | I | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Pdb File Path Index | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Source File Name Index | {{[EI]}} | -CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Symbol Byte Size | -CHECK-NEXT: |----------------------------------------+---| - - Index: test/COFF/pdb-file-static.test =================================================================== --- test/COFF/pdb-file-static.test +++ test/COFF/pdb-file-static.test @@ -43,9 +43,9 @@ # CHECK: ============================================================ # CHECK-LABEL: Mod 0000 | `{{.*}}a.obj`: # CHECK: 232 | S_FILESTATIC [size = 16] `x` -# CHECK-NEXT: type = 0x0074 (int), file name = 1 (D:\src\llvmbuild\cl\Debug\x64\a.obj), flags = enreg global | enreg static +# CHECK-NEXT: type = 0x0074 (int), file name = 2 (D:\src\llvmbuild\cl\Debug\x64\a.obj), flags = enreg global | enreg static # CHECK: Mod 0001 | `{{.*}}b.obj`: # CHECK: 232 | S_FILESTATIC [size = 16] `y` -# CHECK-NEXT: type = 0x0074 (int), file name = 73 (D:\src\llvmbuild\cl\Debug\x64\b.obj), flags = enreg global | enreg static +# CHECK-NEXT: type = 0x0074 (int), file name = 74 (D:\src\llvmbuild\cl\Debug\x64\b.obj), flags = enreg global | enreg static # CHECK-LABEL: Mod 0002 | `* Linker *`: Index: test/COFF/pdb-lib.s =================================================================== --- test/COFF/pdb-lib.s +++ test/COFF/pdb-lib.s @@ -13,15 +13,15 @@ # CHECK-NEXT: ============================================================ # CHECK-NEXT: Mod 0000 | `{{.*pdb-lib.s.tmp[/\\]foo.obj}}`: # CHECK-NEXT: Obj: `{{.*pdb-lib.s.tmp[/\\]foo.obj}}`: -# CHECK-NEXT: debug stream: 9, # files: 0, has ec info: false +# CHECK-NEXT: debug stream: 10, # files: 0, has ec info: false # CHECK-NEXT: pdb file ni: 0 ``, src file ni: 0 `` # CHECK-NEXT: Mod 0001 | `bar.obj`: # CHECK-NEXT: Obj: `{{.*pdb-lib.s.tmp[/\\]bar.lib}}`: -# CHECK-NEXT: debug stream: 10, # files: 0, has ec info: false +# CHECK-NEXT: debug stream: 11, # files: 0, has ec info: false # CHECK-NEXT: pdb file ni: 0 ``, src file ni: 0 `` # CHECK-NEXT: Mod 0002 | `* Linker *`: # CHECK-NEXT: Obj: ``: -# CHECK-NEXT: debug stream: 11, # files: 0, has ec info: false +# CHECK-NEXT: debug stream: 12, # files: 0, has ec info: false # CHECK-NEXT: pdb file ni: 1 `{{.*foo.pdb}}`, src file ni: 0 `` .def _main; Index: test/COFF/pdb-linker-module.test =================================================================== --- test/COFF/pdb-linker-module.test +++ test/COFF/pdb-linker-module.test @@ -4,7 +4,7 @@ MODS: Mod 0001 | `* Linker *` MODS-NEXT: Obj: ``: -MODS-NEXT: debug stream: 10, # files: 0, has ec info: false +MODS-NEXT: debug stream: 12, # files: 0, has ec info: false MODS-NEXT: pdb file ni: 1 `{{.*}}pdb-linker-module.test.tmp.pdb`, src file ni: 0 `` SYMS: Mod 0001 | `* Linker *` Index: test/COFF/pdb-same-name.test =================================================================== --- test/COFF/pdb-same-name.test +++ test/COFF/pdb-same-name.test @@ -15,9 +15,9 @@ RAW-NEXT: ============================================================ RAW-NEXT: Mod 0000 | `foo.obj`: RAW-NEXT: Obj: `{{.*}}1\foo.lib`: -RAW-NEXT: debug stream: 9, # files: 1, has ec info: false +RAW-NEXT: debug stream: 11, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` RAW-NEXT: Mod 0001 | `foo.obj`: RAW-NEXT: Obj: `{{.*}}2\foo.lib`: -RAW-NEXT: debug stream: 10, # files: 1, has ec info: false +RAW-NEXT: debug stream: 12, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` Index: test/COFF/pdb.test =================================================================== --- test/COFF/pdb.test +++ test/COFF/pdb.test @@ -121,15 +121,15 @@ RAW-NEXT: ============================================================ RAW-NEXT: Mod 0000 | `{{.*}}pdb.test.tmp1.obj`: RAW-NEXT: Obj: `{{.*}}pdb.test.tmp1.obj`: -RAW-NEXT: debug stream: 9, # files: 1, has ec info: false +RAW-NEXT: debug stream: 11, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` RAW-NEXT: Mod 0001 | `{{.*}}pdb.test.tmp2.obj`: RAW-NEXT: Obj: `{{.*}}pdb.test.tmp2.obj`: -RAW-NEXT: debug stream: 10, # files: 1, has ec info: false +RAW-NEXT: debug stream: 12, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` RAW-NEXT: Mod 0002 | `* Linker *`: RAW-NEXT: Obj: ``: -RAW-NEXT: debug stream: 11, # files: 0, has ec info: false +RAW-NEXT: debug stream: 13, # files: 0, has ec info: false RAW-NEXT: pdb file ni: 1 `{{.*pdb.test.tmp.pdb}}`, src file ni: 0 `` RAW: Types (TPI Stream) RAW-NEXT: ============================================================