Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lld/COFF/SymbolTable.cpp')
-rw-r--r--lld/COFF/SymbolTable.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index b823ce9eacb5..831ab7d8a7ee 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -15,6 +15,7 @@
#include "llvm/LTO/LTOCodeGenerator.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
+#include <utility>
using namespace llvm;
@@ -173,6 +174,28 @@ Defined *SymbolTable::find(StringRef Name) {
return nullptr;
}
+// Find a given symbol or its mangled symbol.
+std::pair<StringRef, Symbol *> SymbolTable::findMangled(StringRef S) {
+ auto It = Symtab.find(S);
+ if (It != Symtab.end()) {
+ Symbol *Sym = It->second;
+ if (isa<Defined>(Sym->Body))
+ return std::make_pair(S, Sym);
+ }
+
+ // In Microsoft ABI, a non-member function name is mangled this way.
+ std::string Prefix = ("?" + S + "@@Y").str();
+ for (auto I : Symtab) {
+ StringRef Name = I.first;
+ Symbol *Sym = I.second;
+ if (!Name.startswith(Prefix))
+ continue;
+ if (isa<Defined>(Sym->Body))
+ return std::make_pair(Name, Sym);
+ }
+ return std::make_pair(S, nullptr);
+}
+
std::error_code SymbolTable::resolveLazy(StringRef Name) {
auto It = Symtab.find(Name);
if (It == Symtab.end())