[llvm] r323035 - [COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode
Martin Storsjo via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 20 03:44:33 PST 2018
Author: mstorsjo
Date: Sat Jan 20 03:44:32 2018
New Revision: 323035
URL: http://llvm.org/viewvc/llvm-project?rev=323035&view=rev
Log:
[COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode
This (together with the corresponding LLD commit, that contains the
testcase updates) fixes PR35733.
Differential Revision: https://reviews.llvm.org/D41631
Modified:
llvm/trunk/include/llvm/Object/COFFImportFile.h
llvm/trunk/lib/Object/COFFImportFile.cpp
llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
Modified: llvm/trunk/include/llvm/Object/COFFImportFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFFImportFile.h?rev=323035&r1=323034&r2=323035&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFFImportFile.h (original)
+++ llvm/trunk/include/llvm/Object/COFFImportFile.h Sat Jan 20 03:44:32 2018
@@ -98,7 +98,8 @@ struct COFFShortExport {
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
Modified: llvm/trunk/lib/Object/COFFImportFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFImportFile.cpp?rev=323035&r1=323034&r2=323035&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFImportFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFImportFile.cpp Sat Jan 20 03:44:32 2018
@@ -91,7 +91,15 @@ static void writeStringTable(std::vector
}
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 @@ NewArchiveMember ObjectFactory::createWe
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 @@ Error writeImportLibrary(StringRef Impor
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);
Modified: llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp?rev=323035&r1=323034&r2=323035&view=diff
==============================================================================
--- llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp (original)
+++ llvm/trunk/lib/ToolDrivers/llvm-dlltool/DlltoolDriver.cpp Sat Jan 20 03:44:32 2018
@@ -173,7 +173,7 @@ int llvm::dlltoolDriverMain(llvm::ArrayR
}
}
- if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true))
+ if (writeImportLibrary(Def->OutputFile, Path, Def->Exports, Machine, true, true))
return 1;
return 0;
}
More information about the llvm-commits
mailing list