[lld] r298467 - [COFF] Put the PDB next to the image if the user doesn't pass /PDB:

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 21 17:57:14 PDT 2017


Author: rnk
Date: Tue Mar 21 19:57:14 2017
New Revision: 298467

URL: http://llvm.org/viewvc/llvm-project?rev=298467&view=rev
Log:
[COFF] Put the PDB next to the image if the user doesn't pass /PDB:

Summary: This is compatible with MSVC link.exe.

Reviewers: ruiu

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31224

Modified:
    lld/trunk/COFF/Config.h
    lld/trunk/COFF/Driver.cpp
    lld/trunk/test/COFF/rsds.test

Modified: lld/trunk/COFF/Config.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Config.h?rev=298467&r1=298466&r2=298467&view=diff
==============================================================================
--- lld/trunk/COFF/Config.h (original)
+++ lld/trunk/COFF/Config.h Tue Mar 21 19:57:14 2017
@@ -89,7 +89,7 @@ struct Configuration {
   bool Debug = false;
   bool WriteSymtab = true;
   unsigned DebugTypes = static_cast<unsigned>(DebugType::None);
-  StringRef PDBPath;
+  llvm::SmallString<128> PDBPath;
 
   // Symbols in this set are considered as live by the garbage collector.
   std::set<SymbolBody *> GCRoot;

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=298467&r1=298466&r2=298467&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Tue Mar 21 19:57:14 2017
@@ -890,6 +890,12 @@ void LinkerDriver::link(ArrayRef<const c
         getOutputPath((*Args.filtered_begin(OPT_INPUT))->getValue());
   }
 
+  // Put the PDB next to the image if no /pdb flag was passed.
+  if (Config->Debug && Config->PDBPath.empty()) {
+    Config->PDBPath = Config->OutputFile;
+    sys::path::replace_extension(Config->PDBPath, ".pdb");
+  }
+
   // Set default image base if /base is not given.
   if (Config->ImageBase == uint64_t(-1))
     Config->ImageBase = getDefaultImageBase();

Modified: lld/trunk/test/COFF/rsds.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/rsds.test?rev=298467&r1=298466&r2=298467&view=diff
==============================================================================
--- lld/trunk/test/COFF/rsds.test (original)
+++ lld/trunk/test/COFF/rsds.test Tue Mar 21 19:57:14 2017
@@ -4,7 +4,7 @@
 # RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s
 
 # RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:DllMain %t.obj
-# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s -check-prefix CHECK-PDB
+# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s
 
 # CHECK: DebugDirectory [
 # CHECK:   DebugEntry {
@@ -13,37 +13,18 @@
 # CHECK:     MajorVersion: 0x0
 # CHECK:     MinorVersion: 0x0
 # CHECK:     Type: CodeView (0x2)
-# CHECK:     SizeOfData: 0x19
+# CHECK:     SizeOfData:
 # CHECK:     AddressOfRawData:
 # CHECK:     PointerToRawData:
 # CHECK:     PDBInfo {
 # CHECK:       PDBSignature: 0x53445352
 # CHECK:       PDBGUID:
 # CHECK:       PDBAge: 1
-# CHECK:       PDBFileName: {{$}}
+# CHECK:       PDBFileName: {{.*}}.pdb
 # CHECK:     }
 # CHECK:   }
 # CHECK: ]
 
-# CHECK-PDB: DebugDirectory [
-# CHECK-PDB:   DebugEntry {
-# CHECK-PDB:     Characteristics: 0x0
-# CHECK-PDB:     TimeDateStamp: 1970-01-01 00:00:00 (0x0)
-# CHECK-PDB:     MajorVersion: 0x0
-# CHECK-PDB:     MinorVersion: 0x0
-# CHECK-PDB:     Type: CodeView (0x2)
-# CHECK-PDB:     SizeOfData:
-# CHECK-PDB:     AddressOfRawData:
-# CHECK-PDB:     PointerToRawData:
-# CHECK-PDB:     PDBInfo {
-# CHECK-PDB:       PDBSignature: 0x53445352
-# CHECK-PDB:       PDBGUID:
-# CHECK-PDB:       PDBAge: 1
-# CHECK-PDB:       PDBFileName: {{.*}}.pdb
-# CHECK-PDB:     }
-# CHECK-PDB:   }
-# CHECK-PDB: ]
-
 --- !COFF
 header:
   Machine:         IMAGE_FILE_MACHINE_I386




More information about the llvm-commits mailing list