mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 03:29:57 +00:00
[COFF] Keep the underscore on exported decorated stdcall functions in MSVC mode
This fixes PR35733. Differential Revision: https://reviews.llvm.org/D41632 llvm-svn: 323036
This commit is contained in:
parent
f641d0d4f2
commit
3b611fa93f
@ -540,7 +540,7 @@ static void createImportLibrary(bool AsLib) {
|
||||
}
|
||||
|
||||
auto E = writeImportLibrary(getImportName(AsLib), getImplibPath(), Exports,
|
||||
Config->Machine, false);
|
||||
Config->Machine, false, Config->MinGW);
|
||||
handleAllErrors(std::move(E),
|
||||
[&](ErrorInfoBase &EIB) { error(EIB.message()); });
|
||||
}
|
||||
|
@ -558,6 +558,12 @@ err:
|
||||
static StringRef undecorate(StringRef Sym) {
|
||||
if (Config->Machine != I386)
|
||||
return Sym;
|
||||
// In MSVC mode, a fully decorated stdcall function is exported
|
||||
// as-is with the leading underscore (with type IMPORT_NAME).
|
||||
// In MinGW mode, a decorated stdcall function gets the underscore
|
||||
// removed, just like normal cdecl functions.
|
||||
if (Sym.startswith("_") && Sym.contains('@') && !Config->MinGW)
|
||||
return Sym;
|
||||
return Sym.startswith("_") ? Sym.substr(1) : Sym;
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,7 @@
|
||||
# DECORATED-IMPLIB: Name type: name
|
||||
# DECORATED-IMPLIB-NEXT: __imp_@fastcall@8
|
||||
# DECORATED-IMPLIB-NEXT: @fastcall@8
|
||||
# TODO: To match link.exe, this one should also be Name type: name.
|
||||
# DECORATED-IMPLIB: Name type: noprefix
|
||||
# DECORATED-IMPLIB: Name type: name
|
||||
# DECORATED-IMPLIB-NEXT: __imp__stdcall@8
|
||||
# DECORATED-IMPLIB-NEXT: _stdcall@8
|
||||
# DECORATED-IMPLIB: Name type: name
|
||||
@ -41,8 +40,7 @@
|
||||
# DECORATED-IMPLIB-NEXT: vectorcall@@8
|
||||
|
||||
# DECORATED-EXPORTS: Name: @fastcall@8
|
||||
# TODO: To match link.exe, this one should actually be _stdcall@8
|
||||
# DECORATED-EXPORTS: Name: stdcall@8
|
||||
# DECORATED-EXPORTS: Name: _stdcall@8
|
||||
# DECORATED-EXPORTS: Name: vectorcall@@8
|
||||
|
||||
|
||||
|
@ -8,21 +8,19 @@
|
||||
# DECORATED-IMPLIB: Name type: name
|
||||
# DECORATED-IMPLIB-NEXT: __imp_@fastcall@8
|
||||
# DECORATED-IMPLIB-NEXT: @fastcall@8
|
||||
# DECORATED-IMPLIB: Name type: name
|
||||
# DECORATED-IMPLIB-NEXT: __imp__stdcall@8
|
||||
# DECORATED-IMPLIB-NEXT: _stdcall@8
|
||||
# DECORATED-IMPLIB: Name type: noprefix
|
||||
# DECORATED-IMPLIB-NEXT: __imp___underscored
|
||||
# DECORATED-IMPLIB-NEXT: __underscored
|
||||
# TODO: To match link.exe, this one should also be Name type: name.
|
||||
# DECORATED-IMPLIB: Name type: noprefix
|
||||
# DECORATED-IMPLIB-NEXT: __imp__stdcall@8
|
||||
# DECORATED-IMPLIB-NEXT: _stdcall@8
|
||||
# DECORATED-IMPLIB: Name type: name
|
||||
# DECORATED-IMPLIB-NEXT: __imp_vectorcall@@8
|
||||
# DECORATED-IMPLIB-NEXT: vectorcall@@8
|
||||
|
||||
# DECORATED-EXPORTS: Name: @fastcall@8
|
||||
# DECORATED-EXPORTS: Name: _stdcall@8
|
||||
# DECORATED-EXPORTS: Name: _underscored
|
||||
# TODO: To match link.exe, this one should actually be _stdcall@8
|
||||
# DECORATED-EXPORTS: Name: stdcall@8
|
||||
# DECORATED-EXPORTS: Name: vectorcall@@8
|
||||
|
||||
.def _stdcall@8;
|
||||
|
Loading…
Reference in New Issue
Block a user