[ELF] Replace std::set with StringSet.

Wrap functionality was using a std::set to record symbols that need to be
wrapped. This changes the implementation to use a StringSet instead.

No change in functionality.

llvm-svn: 229165
This commit is contained in:
Shankar Easwaran 2015-02-13 22:26:51 +00:00
parent e8dbfe1cf8
commit 8911240c9e
3 changed files with 10 additions and 20 deletions

View File

@ -48,8 +48,6 @@ public:
class ELFLinkingContext : public LinkingContext {
public:
typedef std::set<StringRef>::iterator StringRefSetIterT;
/// \brief The type of ELF executable that the linker
/// creates.
enum class OutputMagic : uint8_t {
@ -300,9 +298,9 @@ public:
}
// --wrap option.
void addWrapForSymbol(StringRef);
void addWrapForSymbol(StringRef sym) { _wrapCalls.insert(sym); }
range<std::set<StringRef>::iterator> wrapCalls() const;
const llvm::StringSet<> &wrapCalls() const { return _wrapCalls; }
private:
ELFLinkingContext() LLVM_DELETED_FUNCTION;
@ -343,7 +341,7 @@ protected:
StringRef _soname;
StringRefVector _rpathList;
StringRefVector _rpathLinkList;
std::set<StringRef> _wrapCalls;
llvm::StringSet<> _wrapCalls;
std::map<std::string, uint64_t> _absoluteSymbols;
llvm::StringSet<> _dynamicallyExportedSymbols;
std::vector<std::unique_ptr<script::Parser>> _scripts;

View File

@ -17,6 +17,7 @@
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Object/ELF.h"
#include "llvm/Object/ObjectFile.h"
@ -763,18 +764,19 @@ template <class ELFT> std::error_code ELFFile<ELFT>::createAtomsFromContext() {
// c) All references to the symbol specified by wrap should point to
// __wrap_<symbolname>
// d) All references to __real_symbol should point to the <symbol>
for (auto wrapsym : _ctx.wrapCalls()) {
for (auto &wrapsym : _ctx.wrapCalls()) {
StringRef wrapStr = wrapsym.getKey();
// Create a undefined symbol fror the wrap symbol.
UndefinedAtom *wrapSymAtom =
new (_readerStorage) SimpleUndefinedAtom(*this, wrapsym);
new (_readerStorage) SimpleUndefinedAtom(*this, wrapStr);
StringRef wrapCallSym =
_ctx.allocateString((llvm::Twine("__wrap_") + wrapsym).str());
_ctx.allocateString((llvm::Twine("__wrap_") + wrapStr).str());
StringRef realCallSym =
_ctx.allocateString((llvm::Twine("__real_") + wrapsym).str());
_ctx.allocateString((llvm::Twine("__real_") + wrapStr).str());
UndefinedAtom *wrapCallAtom =
new (_readerStorage) SimpleUndefinedAtom(*this, wrapCallSym);
// Create maps, when there is call to sym, it should point to wrapCallSym.
_wrapSymbolMap.insert(std::make_pair(wrapsym, wrapCallAtom));
_wrapSymbolMap.insert(std::make_pair(wrapStr, wrapCallAtom));
// Whenever there is a reference to realCall it should point to the symbol
// created for each wrap usage.
_wrapSymbolMap.insert(std::make_pair(realCallSym, wrapSymAtom));

View File

@ -256,14 +256,4 @@ std::string ELFLinkingContext::demangle(StringRef symbolName) const {
return symbolName;
}
// Support --wrap option.
void ELFLinkingContext::addWrapForSymbol(StringRef symbol) {
_wrapCalls.insert(symbol);
}
range<ELFLinkingContext::StringRefSetIterT>
ELFLinkingContext::wrapCalls() const {
return _wrapCalls;
}
} // end namespace lld