[lld] r325316 - Fix an issue that weak bit is dropped when there's a lazy object symbol.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 16 10:46:30 PST 2018


I was thinking about that. But the two classes are annoyingly different in
various places, though they are similar. Maybe we could share more code by
using template or something, but I don't have an idea to do that without
complicating the code.

On Fri, Feb 16, 2018 at 8:14 AM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> Thanks!
>
> It is easy to forget to update the --start-lib case when the .a handling
> changes. I wonder if they could share more code.
>
> Thanks,
> Rafael
>
> Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:
>
> > Author: ruiu
> > Date: Thu Feb 15 20:27:46 2018
> > New Revision: 325316
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=325316&view=rev
> > Log:
> > Fix an issue that weak bit is dropped when there's a lazy object symbol.
> >
> > Previously, we accidentally dropped STB_WEAK bit from an undefined symbol
> > if there is a lazy object symbol with the same name. That caused a
> > compatibility issue with GNU gold.
> >
> > Added:
> >     lld/trunk/test/ELF/weak-undef-lib.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=325316&r1=325315&r2=325316&view=diff
> > ============================================================
> ==================
> > --- lld/trunk/ELF/SymbolTable.cpp (original)
> > +++ lld/trunk/ELF/SymbolTable.cpp Thu Feb 15 20:27:46 2018
> > @@ -568,9 +568,12 @@ void SymbolTable::addLazyObject(StringRe
> >      return;
> >
> >    // See comment for addLazyArchive above.
> > -  if (S->isWeak())
> > +  if (S->isWeak()) {
> >      replaceSymbol<LazyObject>(S, Obj, Name, S->Type);
> > -  else if (InputFile *F = Obj.fetch())
> > +    S->Binding = STB_WEAK;
> > +    return;
> > +  }
> > +  if (InputFile *F = Obj.fetch())
> >      addFile<ELFT>(F);
> >  }
> >
> >
> > Added: lld/trunk/test/ELF/weak-undef-lib.s
> > URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/
> weak-undef-lib.s?rev=325316&view=auto
> > ============================================================
> ==================
> > --- lld/trunk/test/ELF/weak-undef-lib.s (added)
> > +++ lld/trunk/test/ELF/weak-undef-lib.s Thu Feb 15 20:27:46 2018
> > @@ -0,0 +1,19 @@
> > +# REQUIRES: x86
> > +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
> > +# RUN: echo -e '.globl foo\nfoo: ret' | \
> > +# RUN:   llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t2.o
> > +
> > +# RUN: ld.lld -shared -o %t.so %t1.o --start-lib %t2.o
> > +# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s
> > +
> > +# CHECK:      Name: foo
> > +# CHECK-NEXT: Value: 0x0
> > +# CHECK-NEXT: Size: 0
> > +# CHECK-NEXT: Binding: Weak
> > +# CHECK-NEXT: Type: None
> > +# CHECK-NEXT: Other: 0
> > +# CHECK-NEXT: Section: Undefined
> > +
> > +.weak foo
> > +.data
> > +.quad foo
> >
> >
> > _______________________________________________
> > 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/20180216/5824068d/attachment.html>


More information about the llvm-commits mailing list