]> granicus.if.org Git - llvm/commitdiff
Object: preserve more information about DEF file
authorSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 19 Jul 2017 02:01:22 +0000 (02:01 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 19 Jul 2017 02:01:22 +0000 (02:01 +0000)
Preserve the actual library name as provided by the user.  This is
required to properly replicate link's behaviour about the module import
name handling.  This requires an associated change to lld for updating
the tests for the proper behaviour for the import library module name
handling in various cases.

Associated tests will be part of the lld change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308406 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Object/COFFModuleDefinition.h
lib/Object/COFFModuleDefinition.cpp

index 17491b81d5ba4ba7a6970eb62b625d2eb5933a53..be139a2833b0b45c93b55c1a534ba87dd24037f0 100644 (file)
@@ -28,6 +28,7 @@ namespace object {
 struct COFFModuleDefinition {
   std::vector<COFFShortExport> Exports;
   std::string OutputFile;
+  std::string ImportName;
   uint64_t ImageBase = 0;
   uint64_t StackReserve = 0;
   uint64_t StackCommit = 0;
index 5fa06e977fd369e63b677c3d1d5fabfca930b73c..ed9140d1fe08b00426384b8be9c0997940de89b5 100644 (file)
@@ -188,13 +188,17 @@ private:
       std::string Name;
       if (Error Err = parseName(&Name, &Info.ImageBase))
         return Err;
-      // Append the appropriate file extension if not already present.
-      if (!sys::path::has_extension(Name))
-        Name += IsDll ? ".dll" : ".exe";
+
+      Info.ImportName = Name;
 
       // Set the output file, but don't override /out if it was already passed.
-      if (Info.OutputFile.empty())
+      if (Info.OutputFile.empty()) {
         Info.OutputFile = Name;
+        // Append the appropriate file extension if not already present.
+        if (!sys::path::has_extension(Name))
+          Info.OutputFile += IsDll ? ".dll" : ".exe";
+      }
+
       return Error::success();
     }
     case KwVersion: