[PATCH] D41631: [COFF] Keep the underscore on exported decorated stdcall functions

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 29 12:27:30 PST 2017


mstorsjo created this revision.
mstorsjo added reviewers: ruiu, rnk, dmajor.

This (together with the corresponding LLD commit) fixes PR35733.


Repository:
  rL LLVM

https://reviews.llvm.org/D41631

Files:
  include/llvm/Object/COFFImportFile.h
  lib/Object/COFFImportFile.cpp
  lib/Object/COFFModuleDefinition.cpp


Index: lib/Object/COFFModuleDefinition.cpp
===================================================================
--- lib/Object/COFFModuleDefinition.cpp
+++ lib/Object/COFFModuleDefinition.cpp
@@ -243,6 +243,8 @@
     if (Machine == IMAGE_FILE_MACHINE_I386) {
       if (!isDecorated(E.Name, MingwDef))
         E.Name = (std::string("_").append(E.Name));
+      else if (!MingwDef)
+        E.KeepDecoration = true;
       if (!E.ExtName.empty() && !isDecorated(E.ExtName, MingwDef))
         E.ExtName = (std::string("_").append(E.ExtName));
     }
Index: lib/Object/COFFImportFile.cpp
===================================================================
--- lib/Object/COFFImportFile.cpp
+++ lib/Object/COFFImportFile.cpp
@@ -590,6 +590,8 @@
 
     StringRef SymbolName = E.SymbolName.empty() ? E.Name : E.SymbolName;
     ImportNameType NameType = getNameType(SymbolName, E.Name, Machine);
+    if (E.KeepDecoration)
+      NameType = IMPORT_NAME;
     Expected<std::string> Name = E.ExtName.empty()
                                      ? SymbolName
                                      : replace(SymbolName, E.Name, E.ExtName);
Index: include/llvm/Object/COFFImportFile.h
===================================================================
--- include/llvm/Object/COFFImportFile.h
+++ include/llvm/Object/COFFImportFile.h
@@ -80,6 +80,7 @@
   bool Data = false;
   bool Private = false;
   bool Constant = false;
+  bool KeepDecoration = false;
 
   bool isWeak() {
     return ExtName.size() && ExtName != Name;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41631.128341.patch
Type: text/x-patch
Size: 1517 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171229/b99de9df/attachment.bin>


More information about the llvm-commits mailing list