mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-08 02:18:43 +00:00
lld-link: Also demangle undefined dllimported symbols.
dllimported symbols go through an import stub that's called __imp_ followed by the name the stub points to. Make that work. Differential Revision: https://reviews.llvm.org/D52145 llvm-svn: 342401
This commit is contained in:
parent
06d3b4139e
commit
5ffd8cedf4
@ -38,14 +38,20 @@ Optional<std::string> lld::demangleItanium(StringRef Name) {
|
||||
}
|
||||
|
||||
Optional<std::string> lld::demangleMSVC(StringRef Name) {
|
||||
std::string Prefix;
|
||||
if (Name.consume_front("__imp_"))
|
||||
Prefix = "__declspec(dllimport) ";
|
||||
|
||||
// Demangle only C++ names.
|
||||
if (!Name.startswith("?"))
|
||||
return None;
|
||||
|
||||
char *Buf = microsoftDemangle(Name.str().c_str(), nullptr, nullptr, nullptr);
|
||||
if (!Buf)
|
||||
return None;
|
||||
std::string S(Buf);
|
||||
free(Buf);
|
||||
return S;
|
||||
return Prefix + S;
|
||||
}
|
||||
|
||||
StringMatcher::StringMatcher(ArrayRef<StringRef> Pat) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(main)
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(f1)
|
||||
# CHECK-EMPTY:
|
||||
# CHECK-NEXT: error: undefined symbol: "int __cdecl baz(void)" (?baz@@YAHXZ)
|
||||
# CHECK-NEXT: error: undefined symbol: "__declspec(dllimport) int __cdecl baz(void)" (__imp_?baz@@YAHXZ)
|
||||
# CHECK-NEXT: >>> referenced by {{.*}}.obj:(f2)
|
||||
|
||||
.section .text,"xr",one_only,main
|
||||
@ -27,4 +27,4 @@ f1:
|
||||
.section .text,"xr",one_only,f2
|
||||
.globl f2
|
||||
f2:
|
||||
call "?baz@@YAHXZ"
|
||||
callq *"__imp_?baz@@YAHXZ"(%rip)
|
||||
|
Loading…
x
Reference in New Issue
Block a user