[lld] r323221 - Don't mark a shared library as needed because of a lazy symbol.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 23 12:31:46 PST 2018
I think this needs to be cherry picked for 6.0.
On Tue, Jan 23, 2018 at 8:59 AM, Rafael Espindola via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: rafael
> Date: Tue Jan 23 08:59:20 2018
> New Revision: 323221
>
> URL: http://llvm.org/viewvc/llvm-project?rev=323221&view=rev
> Log:
> Don't mark a shared library as needed because of a lazy symbol.
>
> Fixes PR36029.
>
> Added:
> lld/trunk/test/ELF/Inputs/as-needed-lazy.s
> lld/trunk/test/ELF/as-needed-lazy.s
> Modified:
> lld/trunk/ELF/SymbolTable.cpp
>
> Modified: lld/trunk/ELF/SymbolTable.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/
> SymbolTable.cpp?rev=323221&r1=323220&r2=323221&view=diff
> ============================================================
> ==================
> --- lld/trunk/ELF/SymbolTable.cpp (original)
> +++ lld/trunk/ELF/SymbolTable.cpp Tue Jan 23 08:59:20 2018
> @@ -491,12 +491,13 @@ void SymbolTable::addShared(StringRef Na
> if (WasInserted ||
> ((S->isUndefined() || S->isLazy()) && S->Visibility ==
> STV_DEFAULT)) {
> uint8_t Binding = S->Binding;
> + bool WasUndefined = S->isUndefined();
> replaceSymbol<SharedSymbol>(S, File, Name, Sym.getBinding(),
> Sym.st_other,
> Sym.getType(), Sym.st_value, Sym.st_size,
> Alignment, VerdefIndex);
> if (!WasInserted) {
> S->Binding = Binding;
> - if (!S->isWeak() && !Config->GcSections)
> + if (!S->isWeak() && !Config->GcSections && WasUndefined)
> File.IsNeeded = true;
> }
> }
>
> Added: lld/trunk/test/ELF/Inputs/as-needed-lazy.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> Inputs/as-needed-lazy.s?rev=323221&view=auto
> ============================================================
> ==================
> --- lld/trunk/test/ELF/Inputs/as-needed-lazy.s (added)
> +++ lld/trunk/test/ELF/Inputs/as-needed-lazy.s Tue Jan 23 08:59:20 2018
> @@ -0,0 +1,3 @@
> +.global foo
> +foo:
> + nop
>
> Added: lld/trunk/test/ELF/as-needed-lazy.s
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/as-
> needed-lazy.s?rev=323221&view=auto
> ============================================================
> ==================
> --- lld/trunk/test/ELF/as-needed-lazy.s (added)
> +++ lld/trunk/test/ELF/as-needed-lazy.s Tue Jan 23 08:59:20 2018
> @@ -0,0 +1,14 @@
> +# REQUIRES: x86
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux
> %p/Inputs/as-needed-lazy.s -o %t2.o
> +# RUN: ld.lld %t2.o -o %t2.so -shared
> +# RUN: rm -f %t2.a
> +# RUN: llvm-ar rc %t2.a %t2.o
> +# RUN: ld.lld %t1.o %t2.a --as-needed %t2.so -o %t
> +# RUN: llvm-readobj -d %t | FileCheck %s
> +
> +# CHECK-NOT: NEEDED
> +
> +.global _start
> +_start:
> + nop
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180123/d67e450b/attachment.html>
More information about the llvm-commits
mailing list