forked from OSchip/llvm-project
[LLD] [COFF] Always demangle the __imp_ prefix to __declspec(dllimport)
Differential Revision: https://reviews.llvm.org/D68017 llvm-svn: 373781
This commit is contained in:
parent
174604c93c
commit
9809ed6135
|
@ -30,14 +30,16 @@ static_assert(sizeof(SymbolUnion) <= 48,
|
|||
static std::string maybeDemangleSymbol(StringRef symName) {
|
||||
if (config->demangle) {
|
||||
std::string prefix;
|
||||
StringRef demangleInput = symName;
|
||||
if (demangleInput.consume_front("__imp_"))
|
||||
StringRef prefixless = symName;
|
||||
if (prefixless.consume_front("__imp_"))
|
||||
prefix = "__declspec(dllimport) ";
|
||||
StringRef demangleInput = prefixless;
|
||||
if (config->machine == I386)
|
||||
demangleInput.consume_front("_");
|
||||
std::string demangled = demangle(demangleInput);
|
||||
if (demangled != demangleInput)
|
||||
return prefix + demangled;
|
||||
return prefix + demangle(demangleInput);
|
||||
return (prefix + prefixless).str();
|
||||
}
|
||||
return symName;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# RUN: /alternatename:__delayLoadHelper2=main /opt:noref >& %t.log
|
||||
# RUN: FileCheck %s < %t.log
|
||||
|
||||
# CHECK: cannot delay-load foo.dll due to import of data: __imp_datasym
|
||||
# CHECK: cannot delay-load foo.dll due to import of data: __declspec(dllimport) datasym
|
||||
|
||||
--- !COFF
|
||||
header:
|
||||
|
|
|
@ -9,5 +9,5 @@ CHECK-ALPHA: error: duplicate symbol: f in {{.*}}alpha.obj and in alpha.dll
|
|||
RUN: llc -mtriple x86_64-windows-msvc -filetype obj -o gamma.obj %S/Inputs/gamma.ll
|
||||
RUN: not lld-link /out:gamma.exe /subsystem:console /entry:mainCRTStartup gamma.obj alpha.lib 2>&1 | FileCheck %s -check-prefix CHECK-GAMMA
|
||||
|
||||
CHECK-GAMMA: error: duplicate symbol: __imp_f in {{.*}}gamma.obj and in alpha.dll
|
||||
CHECK-GAMMA: error: duplicate symbol: __declspec(dllimport) f in {{.*}}gamma.obj and in alpha.dll
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
# NODEMANGLE: error: undefined symbol: __Z3barPKc
|
||||
# NODEMANGLE: error: undefined symbol: __imp___Z3bazv
|
||||
# NODEMANGLE: error: undefined symbol: _Z3fooi
|
||||
# NODEMANGLE: error: undefined symbol: __imp__cfunc
|
||||
|
||||
# CHECK: error: undefined symbol: foo(int)
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.o:(_main)
|
||||
|
@ -21,6 +22,9 @@
|
|||
# CHECK-NEXT: >>> referenced by {{.*}}.o:(_f2)
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: error: undefined symbol: _Z3fooi
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.o:(_f2)
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: error: undefined symbol: __declspec(dllimport) _cfunc
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.o:(_f2)
|
||||
|
||||
.section .text,"xr",one_only,_main
|
||||
|
@ -39,3 +43,4 @@ _f1:
|
|||
_f2:
|
||||
call *__imp___Z3bazv
|
||||
call _Z3fooi
|
||||
call *__imp__cfunc
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
# CHECK-NEXT: error: undefined symbol: __declspec(dllimport) int __cdecl baz(void)
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(f2)
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: error: undefined symbol: __imp_undecorated
|
||||
# CHECK-NEXT: error: undefined symbol: __declspec(dllimport) undecorated
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(f2)
|
||||
|
||||
.section .text,"xr",one_only,main
|
||||
|
|
Loading…
Reference in New Issue