[PATCH] D63182: [ELF][PPC64] Don't report "relocation refers to a discarded section" for .toc

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 00:17:30 PDT 2019


ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: ELF/Relocations.cpp:721
 
+  // clang/gcc PPC64 may emit a .rela.toc which references a switch table in a
+  // discarded .rodata/.text section. The .toc and the .rela.toc are incorrectly
----------------
MaskRay wrote:
> ruiu wrote:
> > Hmm, has the compiler bug fixed? At least someone needs to fix this so that the compilers don't emit wrong code.
> Not yet.. Latest clang and powerpc64le gcc 6 (available on goldbolt.org) have the bug. You can find a reference from .toc to a local label in .rodata.blah (clang) or .text.blah (clang). The reference is a section relative relocation.
> 
> ```
> void puts(const char *);
> 
> struct A {
>   void foo(int a) {
>     switch (a) {
>     case 0: puts("0"); break;
>     case 1: puts("1"); puts("1"); break;
>     case 2: puts("2"); break;
>     case 3: puts("3"); puts("4"); break;
>     case 4: puts("4"); break;
>     case 5: puts("5"); puts("5"); break;
>     case 6: puts("6"); break;
>     }
>   }
>   int a;
> };
> 
> void foo(A x) {
>   x.foo(x.a);
> }
> ```
OK. We are not responsible for fixing the compiler issues, but we need to take a note which versions of the compilers have that bug. Please include that information to the comment.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63182/new/

https://reviews.llvm.org/D63182





More information about the llvm-commits mailing list