[lld] r241874 - COFF: Find C++ mangled name for symbols starting with underscore.
Rui Ueyama
ruiu at google.com
Thu Jul 9 16:03:51 PDT 2015
Author: ruiu
Date: Thu Jul 9 18:03:51 2015
New Revision: 241874
URL: http://llvm.org/viewvc/llvm-project?rev=241874&view=rev
Log:
COFF: Find C++ mangled name for symbols starting with underscore.
Symbol foo is mangled as _foo in C and ?foo@@... in C++ on x86.
findMangle has to remove prefix underscore before mangle a given name
as a C++ symbol.
Modified:
lld/trunk/COFF/SymbolTable.cpp
lld/trunk/test/COFF/export32.test
Modified: lld/trunk/COFF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/SymbolTable.cpp?rev=241874&r1=241873&r2=241874&view=diff
==============================================================================
--- lld/trunk/COFF/SymbolTable.cpp (original)
+++ lld/trunk/COFF/SymbolTable.cpp Thu Jul 9 18:03:51 2015
@@ -281,7 +281,14 @@ void SymbolTable::mangleMaybe(Undefined
return;
// In Microsoft ABI, a non-member function name is mangled this way.
- std::string Prefix = ("?" + U->getName() + "@@Y").str();
+ std::string Prefix;
+ if (Config->is64()) {
+ Prefix = ("?" + U->getName() + "@@Y").str();
+ } else {
+ if (!U->getName().startswith("_"))
+ return;
+ Prefix = ("?" + U->getName().substr(1) + "@@Y").str();
+ }
for (auto Pair : Symtab) {
StringRef Name = Pair.first;
if (!Name.startswith(Prefix))
Modified: lld/trunk/test/COFF/export32.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/export32.test?rev=241874&r1=241873&r2=241874&view=diff
==============================================================================
--- lld/trunk/test/COFF/export32.test (original)
+++ lld/trunk/test/COFF/export32.test Thu Jul 9 18:03:51 2015
@@ -10,7 +10,8 @@ CHECK1-NEXT: 0 0
CHECK1-NEXT: 1 0x1008 exportfn1
CHECK1-NEXT: 2 0x1010 exportfn2
-# RUN: lld -flavor link2 /out:%t.dll /dll %t.obj /export:exportfn1, at 5 /export:exportfn2
+# RUN: lld -flavor link2 /out:%t.dll /dll %t.obj /export:exportfn1, at 5 \
+# RUN: /export:exportfn2 /export:mangled
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK2 %s
CHECK2: Export Table:
@@ -24,6 +25,7 @@ CHECK2-NEXT: 4 0
CHECK2-NEXT: 5 0x1008 exportfn1
CHECK2-NEXT: 6 0x1010 exportfn2
CHECK2-NEXT: 7 0x1010 exportfn3
+CHECK2-NEXT: 8 0x1010 mangled
# RUN: lld -flavor link2 /out:%t.dll /dll %t.obj /export:exportfn1, at 5,noname /export:exportfn2
# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK3 %s
More information about the llvm-commits
mailing list