[lld] r218705 - [PECOFF] Move helper function out of class
Rui Ueyama
ruiu at google.com
Tue Sep 30 14:39:46 PDT 2014
Author: ruiu
Date: Tue Sep 30 16:39:46 2014
New Revision: 218705
URL: http://llvm.org/viewvc/llvm-project?rev=218705&view=rev
Log:
[PECOFF] Move helper function out of class
No functionality change intended.
Added:
lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.cpp
Modified:
lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt
lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
Modified: lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt?rev=218705&r1=218704&r2=218705&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/CMakeLists.txt Tue Sep 30 16:39:46 2014
@@ -1,6 +1,7 @@
add_lld_library(lldPECOFF
EdataPass.cpp
IdataPass.cpp
+ LinkerGeneratedSymbolFile.cpp
LoadConfigPass.cpp
PECOFFLinkingContext.cpp
Pass.cpp
Added: lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.cpp?rev=218705&view=auto
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.cpp (added)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.cpp Tue Sep 30 16:39:46 2014
@@ -0,0 +1,48 @@
+//===- lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.cpp --------------===//
+//
+// The LLVM Linker
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LinkerGeneratedSymbolFile.h"
+
+namespace lld {
+namespace pecoff {
+
+// Find decorated symbol, namely /sym@[0-9]+/ or /\?sym@@.+/.
+bool findDecoratedSymbol(PECOFFLinkingContext *ctx, ResolvableSymbols *syms,
+ std::string sym, std::string &res) {
+ const std::set<std::string> &defined = syms->defined();
+ // Search for /sym@[0-9]+/
+ {
+ std::string s = sym + '@';
+ auto it = defined.lower_bound(s);
+ for (auto e = defined.end(); it != e; ++it) {
+ if (!StringRef(*it).startswith(s))
+ break;
+ if (it->size() == s.size())
+ continue;
+ StringRef suffix = StringRef(*it).substr(s.size());
+ if (suffix.find_first_not_of("0123456789") != StringRef::npos)
+ continue;
+ res = *it;
+ return true;
+ }
+ }
+ // Search for /\?sym@@.+/
+ {
+ std::string s = "?" + ctx->undecorateSymbol(sym).str() + "@@";
+ auto it = defined.lower_bound(s);
+ if (it != defined.end() && StringRef(*it).startswith(s)) {
+ res = *it;
+ return true;
+ }
+ }
+ return false;
+}
+
+} // namespace pecoff
+} // namespace lld
Modified: lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h?rev=218705&r1=218704&r2=218705&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h (original)
+++ lld/trunk/lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h Tue Sep 30 16:39:46 2014
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.cpp --------------===//
+//===- lib/ReaderWriter/PECOFF/LinkerGeneratedSymbolFile.h ----------------===//
//
// The LLVM Linker
//
@@ -21,6 +21,10 @@ using llvm::COFF::WindowsSubsystem;
namespace lld {
namespace pecoff {
+class ResolvableSymbols;
+bool findDecoratedSymbol(PECOFFLinkingContext *ctx, ResolvableSymbols *syms,
+ std::string sym, std::string &res);
+
namespace impl {
/// The defined atom for dllexported symbols with __imp_ prefix.
@@ -255,7 +259,7 @@ public:
if (it == _exportedSyms.end())
return nullptr;
std::string replace;
- if (!findDecoratedSymbol(sym.str(), replace))
+ if (!findDecoratedSymbol(_ctx, _syms.get(), sym.str(), replace))
return nullptr;
it->second->name = replace;
if (_ctx->deadStrip())
@@ -264,37 +268,6 @@ public:
}
private:
- // Find decorated symbol, namely /sym@[0-9]+/ or /\?sym@@.+/.
- bool findDecoratedSymbol(std::string sym, std::string &res) const {
- const std::set<std::string> &defined = _syms->defined();
- // Search for /sym@[0-9]+/
- {
- std::string s = sym + '@';
- auto it = defined.lower_bound(s);
- for (auto e = defined.end(); it != e; ++it) {
- if (!StringRef(*it).startswith(s))
- break;
- if (it->size() == s.size())
- continue;
- StringRef suffix = StringRef(*it).substr(s.size());
- if (suffix.find_first_not_of("0123456789") != StringRef::npos)
- continue;
- res = *it;
- return true;
- }
- }
- // Search for /\?sym@@.+/
- {
- std::string s = "?" + _ctx->undecorateSymbol(sym).str() + "@@";
- auto it = defined.lower_bound(s);
- if (it != defined.end() && StringRef(*it).startswith(s)) {
- res = *it;
- return true;
- }
- }
- return false;
- }
-
std::map<std::string, PECOFFLinkingContext::ExportDesc *> _exportedSyms;
std::shared_ptr<ResolvableSymbols> _syms;
mutable llvm::BumpPtrAllocator _alloc;
More information about the llvm-commits
mailing list