[PATCH] D41631: [COFF] Keep the underscore on exported decorated stdcall functions
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 14 14:19:05 PST 2018
mstorsjo updated this revision to Diff 129793.
mstorsjo added a comment.
Herald added a subscriber: mehdi_amini.
The matching change to the update of https://reviews.llvm.org/D41632.
https://reviews.llvm.org/D41631
Files:
include/llvm/Object/COFFImportFile.h
lib/Object/COFFImportFile.cpp
lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
Index: lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
===================================================================
--- lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
+++ lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
@@ -173,7 +173,7 @@
}
}
- if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true))
+ if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true, true))
return 1;
return 0;
}
Index: lib/Object/COFFImportFile.cpp
===================================================================
--- lib/Object/COFFImportFile.cpp
+++ lib/Object/COFFImportFile.cpp
@@ -91,7 +91,15 @@
}
static ImportNameType getNameType(StringRef Sym, StringRef ExtName,
- MachineTypes Machine) {
+ MachineTypes Machine, bool MinGW) {
+ // A decorated stdcall function in MSVC is exported with the
+ // type IMPORT_NAME, and the exported function name includes the
+ // the leading underscore. In MinGW on the other hand, a decorated
+ // stdcall function still omits the underscore (IMPORT_NAME_NOPREFIX).
+ // See the comment in isDecorated in COFFModuleDefinition.cpp for more
+ // details.
+ if (ExtName.startswith("_") && ExtName.contains('@') && !MinGW)
+ return IMPORT_NAME;
if (Sym != ExtName)
return IMPORT_NAME_UNDECORATE;
if (Machine == IMAGE_FILE_MACHINE_I386 && Sym.startswith("_"))
@@ -558,7 +566,8 @@
Error writeImportLibrary(StringRef ImportName, StringRef Path,
ArrayRef<COFFShortExport> Exports,
- MachineTypes Machine, bool MakeWeakAliases) {
+ MachineTypes Machine, bool MakeWeakAliases,
+ bool MinGW) {
std::vector<NewArchiveMember> Members;
ObjectFactory OF(llvm::sys::path::filename(ImportName), Machine);
@@ -589,7 +598,7 @@
ImportType = IMPORT_CONST;
StringRef SymbolName = E.SymbolName.empty() ? E.Name : E.SymbolName;
- ImportNameType NameType = getNameType(SymbolName, E.Name, Machine);
+ ImportNameType NameType = getNameType(SymbolName, E.Name, Machine, MinGW);
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
@@ -98,7 +98,8 @@
Error writeImportLibrary(StringRef ImportName, StringRef Path,
ArrayRef<COFFShortExport> Exports,
- COFF::MachineTypes Machine, bool MakeWeakAliases);
+ COFF::MachineTypes Machine, bool MakeWeakAliases,
+ bool MinGW);
} // namespace object
} // namespace llvm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41631.129793.patch
Type: text/x-patch
Size: 2916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180114/c0307aae/attachment.bin>
More information about the llvm-commits
mailing list