<div dir="ltr">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.</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 16, 2018 at 8:14 AM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks!<br>
<br>
It is easy to forget to update the --start-lib case when the .a handling<br>
changes. I wonder if they could share more code.<br>
<br>
Thanks,<br>
Rafael<br>
<div class="HOEnZb"><div class="h5"><br>
Rui Ueyama via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> writes:<br>
<br>
> Author: ruiu<br>
> Date: Thu Feb 15 20:27:46 2018<br>
> New Revision: 325316<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=325316&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=325316&view=rev</a><br>
> Log:<br>
> Fix an issue that weak bit is dropped when there's a lazy object symbol.<br>
><br>
> Previously, we accidentally dropped STB_WEAK bit from an undefined symbol<br>
> if there is a lazy object symbol with the same name. That caused a<br>
> compatibility issue with GNU gold.<br>
><br>
> Added:<br>
>     lld/trunk/test/ELF/weak-undef-<wbr>lib.s<br>
> Modified:<br>
>     lld/trunk/ELF/SymbolTable.cpp<br>
><br>
> Modified: lld/trunk/ELF/SymbolTable.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=325316&r1=325315&r2=325316&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/<wbr>SymbolTable.cpp?rev=325316&r1=<wbr>325315&r2=325316&view=diff</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/ELF/SymbolTable.cpp (original)<br>
> +++ lld/trunk/ELF/SymbolTable.cpp Thu Feb 15 20:27:46 2018<br>
> @@ -568,9 +568,12 @@ void SymbolTable::addLazyObject(<wbr>StringRe<br>
>      return;<br>
><br>
>    // See comment for addLazyArchive above.<br>
> -  if (S->isWeak())<br>
> +  if (S->isWeak()) {<br>
>      replaceSymbol<LazyObject>(S, Obj, Name, S->Type);<br>
> -  else if (InputFile *F = Obj.fetch())<br>
> +    S->Binding = STB_WEAK;<br>
> +    return;<br>
> +  }<br>
> +  if (InputFile *F = Obj.fetch())<br>
>      addFile<ELFT>(F);<br>
>  }<br>
><br>
><br>
> Added: lld/trunk/test/ELF/weak-undef-<wbr>lib.s<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/weak-undef-lib.s?rev=325316&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/test/ELF/<wbr>weak-undef-lib.s?rev=325316&<wbr>view=auto</a><br>
> ==============================<wbr>==============================<wbr>==================<br>
> --- lld/trunk/test/ELF/weak-undef-<wbr>lib.s (added)<br>
> +++ lld/trunk/test/ELF/weak-undef-<wbr>lib.s Thu Feb 15 20:27:46 2018<br>
> @@ -0,0 +1,19 @@<br>
> +# REQUIRES: x86<br>
> +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o<br>
> +# RUN: echo -e '.globl foo\nfoo: ret' | \<br>
> +# RUN:   llvm-mc -filetype=obj -triple=x86_64-pc-linux - -o %t2.o<br>
> +<br>
> +# RUN: ld.lld -shared -o %t.so %t1.o --start-lib %t2.o<br>
> +# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s<br>
> +<br>
> +# CHECK:      Name: foo<br>
> +# CHECK-NEXT: Value: 0x0<br>
> +# CHECK-NEXT: Size: 0<br>
> +# CHECK-NEXT: Binding: Weak<br>
> +# CHECK-NEXT: Type: None<br>
> +# CHECK-NEXT: Other: 0<br>
> +# CHECK-NEXT: Section: Undefined<br>
> +<br>
> +.weak foo<br>
> +.data<br>
> +.quad foo<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>