<div dir="ltr">I think the .toc bug has never been fixed in clang so there is no revision that introduced the regression. I added the date as requested in the review.<div><br></div><div>> Again would've been nice to have a revision for when the errors started happening, so this fixed could be correlated to the breaking change.</div><div><br></div><div>The ppc64le-lld-multistage-test buildbot was down for a while during my fix and some links were not available after it was up again...</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 25, 2019 at 9:34 PM Hans Wennborg <<a href="mailto:hans@chromium.org">hans@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Wed, Jun 12, 2019 at 9:32 AM Fangrui Song via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: maskray<br>
> Date: Wed Jun 12 00:35:42 2019<br>
> New Revision: 363126<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=363126&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=363126&view=rev</a><br>
> Log:<br>
> [ELF][PPC64] Don't report "relocation refers to a discarded section" for .toc<br>
><br>
> Summary:<br>
> clang (as of 2019-06-12) / gcc (as of 8.2.1) PPC64 may emit a .rela.toc<br>
<br>
Why a date instead of a specific revision number? The date gives the<br>
reader no clue of what Clang change introduced this.<br>
<br>
> which references an embedded switch table in a discarded .rodata/.text<br>
> section. The .toc and the .rela.toc are incorrectly not placed in the<br>
> comdat.<br>
><br>
> Technically a relocation from outside the group is not allowed by the ELF spec:<br>
><br>
> > A symbol table entry with STB_LOCAL binding that is defined relative<br>
> > to one of a group's sections, and that is contained in a symbol table<br>
> > section that is not part of the group, must be discarded if the group<br>
> > members are discarded. References to this symbol table entry from<br>
> > outside the group are not allowed.<br>
><br>
> Don't report errors to work around the bug.<br>
><br>
> This should fix the ppc64le-lld-multistage-test bot while linking llvm-tblgen:<br>
<br>
Again would've been nice to have a revision for when the errors<br>
started happening, so this fixed could be correlated to the breaking<br>
change.<br>
<br>
><br>
>     ld.lld: error: relocation refers to a discarded section: .rodata._ZNK4llvm3MVT13getSizeInBitsEv<br>
>     >>> defined in utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenRegisters.cpp.o<br>
>     >>> referenced by CodeGenRegisters.cpp<br>
>     >>> utils/TableGen/CMakeFiles/llvm-tblgen.dir/CodeGenRegisters.cpp.o:(.toc+0x0)<br>
><br>
> Some other PPC specific sections may have similar problems. We can blacklist more<br>
> section names when problems occur.<br>
><br>
>     // A simple program that reproduces the bug.<br>
>     // Note .rela.toc (outside the group) references a section symbol (STB_LOCAL) in a group.<br>
>     void puts(const char *);<br>
>     struct A {<br>
>       void foo(int a) {<br>
>         switch (a) {<br>
>         case 0: puts("0"); break;<br>
>         case 1: puts("1"); puts("1"); break;<br>
>         case 2: puts("2"); break;<br>
>         case 3: puts("3"); puts("4"); break;<br>
>         case 4: puts("4"); break;<br>
>         case 5: puts("5"); puts("5"); break;<br>
>         case 6: puts("6"); break;<br>
>         }<br>
>       }<br>
>       int a;<br>
>     };<br>
>     void foo(A x) { x.foo(x.a); }<br>
><br>
> Reviewers: ruiu, sfertile, espindola<br>
><br>
> Reviewed By: ruiu<br>
><br>
> Subscribers: emaste, nemanjai, arichardson, kbarton, jsji, llvm-commits<br>
><br>
> Tags: #llvm<br>
><br>
> Differential Revision: <a href="https://reviews.llvm.org/D63182" rel="noreferrer" target="_blank">https://reviews.llvm.org/D63182</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">宋方睿</div></div>