[lld] r335337 - [ELF] - Change how we handle suplicate -wrap. [NFC]
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 22 04:18:11 PDT 2018
Author: grimar
Date: Fri Jun 22 04:18:11 2018
New Revision: 335337
URL: http://llvm.org/viewvc/llvm-project?rev=335337&view=rev
Log:
[ELF] - Change how we handle suplicate -wrap. [NFC]
This avoids doing llvm::sort and std::unique for -wrap options.
I think it is more clean way.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/SymbolTable.cpp
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=335337&r1=335336&r2=335337&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Jun 22 04:18:11 2018
@@ -1304,11 +1304,8 @@ template <class ELFT> void LinkerDriver:
Symtab->scanVersionScript();
// Create wrapped symbols for -wrap option.
- std::vector<std::string> Wraps = Args.getAllArgValues(OPT_wrap);
- llvm::sort(Wraps.begin(), Wraps.end());
- Wraps.erase(std::unique(Wraps.begin(), Wraps.end()), Wraps.end());
- for (StringRef Name : Wraps)
- Symtab->addSymbolWrap<ELFT>(Name);
+ for (auto *Arg : Args.filtered(OPT_wrap))
+ Symtab->addSymbolWrap<ELFT>(Arg->getValue());
// Do link-time optimization if given files are LLVM bitcode files.
// This compiles bitcode files into real object files.
Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=335337&r1=335336&r2=335337&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Fri Jun 22 04:18:11 2018
@@ -158,6 +158,13 @@ template <class ELFT> void SymbolTable::
Symbol *Sym = find(Name);
if (!Sym)
return;
+
+ // Do not wrap the same symbol twice.
+ if (llvm::find_if(WrappedSymbols, [&](const WrappedSymbol &S) {
+ return S.Sym == Sym;
+ }) != WrappedSymbols.end())
+ return;
+
Symbol *Real = addUndefined<ELFT>(Saver.save("__real_" + Name));
Symbol *Wrap = addUndefined<ELFT>(Saver.save("__wrap_" + Name));
WrappedSymbols.push_back({Sym, Real, Wrap});
More information about the llvm-commits
mailing list