[lld] r334991 - [ELF] Uniquify --wrap list.
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 18 15:32:15 PDT 2018
Author: maskray
Date: Mon Jun 18 15:32:15 2018
New Revision: 334991
URL: http://llvm.org/viewvc/llvm-project?rev=334991&view=rev
Log:
[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
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/test/ELF/wrap.s
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=334991&r1=334990&r2=334991&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Mon Jun 18 15:32:15 2018
@@ -1303,8 +1303,11 @@ template <class ELFT> void LinkerDriver:
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.
Modified: lld/trunk/test/ELF/wrap.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/wrap.s?rev=334991&r1=334990&r2=334991&view=diff
==============================================================================
--- lld/trunk/test/ELF/wrap.s (original)
+++ lld/trunk/test/ELF/wrap.s Mon Jun 18 15:32:15 2018
@@ -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
More information about the llvm-commits
mailing list