[ELF] Uniquify --wrap list.

Summary: For --wrap foo --wrap foo, bfd/gold wrap the symbol only once but LLD would rotate it twice.

Reviewers: ruiu, espindola

Subscribers: emaste, arichardson, mgrang, llvm-commits

Differential Revision: https://reviews.llvm.org/D48298

llvm-svn: 334991
This commit is contained in:
Fangrui Song 2018-06-18 22:32:15 +00:00
parent 88bbad24c0
commit d9c3c1cd9d
2 changed files with 7 additions and 2 deletions

View File

@ -1303,8 +1303,11 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
Symtab->scanVersionScript();
// Create wrapped symbols for -wrap option.
for (auto *Arg : Args.filtered(OPT_wrap))
Symtab->addSymbolWrap<ELFT>(Arg->getValue());
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);
// Do link-time optimization if given files are LLVM bitcode files.
// This compiles bitcode files into real object files.

View File

@ -6,6 +6,8 @@
// RUN: llvm-objdump -d -print-imm-hex %t3 | FileCheck %s
// RUN: ld.lld -o %t3 %t %t2 --wrap foo -wrap=nosuchsym
// RUN: llvm-objdump -d -print-imm-hex %t3 | FileCheck %s
// RUN: ld.lld -o %t3 %t %t2 --wrap foo --wrap foo -wrap=nosuchsym
// RUN: llvm-objdump -d -print-imm-hex %t3 | FileCheck %s
// CHECK: _start:
// CHECK-NEXT: movl $0x11010, %edx