[PATCH] D83244: [lld] Don't error out on relocations in .gcc_except_table to discarded sections.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 17:46:45 PDT 2020


MaskRay added a comment.

In D83244#2135329 <https://reviews.llvm.org/D83244#2135329>, @abidh wrote:

> In D83244#2133669 <https://reviews.llvm.org/D83244#2133669>, @MaskRay wrote:
>
> > The `.eh_frame` test case is invalid. LLD handles .eh_frame input sections differently. It parses .eh_frame and deduplicates them. See `eh-frame-merge.s`, an input .eh_frame referencing a non-prevailing COMDAT group is dropped (EhFrameSection::isFdeLive)
> >
> > Do you have a realistic case where LLD erroneously errors? If so, can you get a minimal reproduce, use `LLD_REPRODUCE=/tmp/rep.tar` or `-Wl,--reproduce=/tmp/rep.tar` to get a reproduce file and upload it somewhere?
>
>
> The problem that I faced is with gcc_except_table. I added .eh_frame for completion sake.  The problem was coming while linking in libc++ for a beremetal target. I will try if I can get a minimal testcase from that but it may be difficult. The error looks like this:
>
> ld.lld: error: relocation refers to a symbol in a discarded section:
>
> >>> defined in /opt/llvm/lib/clang-runtimes/riscv64-unknown-elf/rv64imac/lp64/medany/lib/libc++.a(locale.cpp.o)
> >>>  section group signature: _ZNSt3__116__pad_and_outputIcNS_11char_traitsIcEEEENS_19ostreambuf_iteratorIT_T0_EES6_PKS4_S8_S8_RNS_8ios_baseES4_
> >>>  prevailing definition is in /tmp/test-48f00f.o
> >>>  referenced by locale.cpp
> >>> 
> >>>   locale.cpp.o:(.gcc_except_table+0x6FD) in archive /opt/llvm/lib/clang-runtimes/riscv64-unknown-elf/rv64imac/lp64/medany/lib/libc++.a
> >>> 
> >>> referenced by locale.cpp
> >>> 
> >>>   locale.cpp.o:(.gcc_except_table+0x706) in archive /opt/llvm/lib/clang-runtimes/riscv64-unknown-elf/rv64imac/lp64/medany/lib/libc++.a
> >>> 
> >>> referenced by locale.cpp
> >>> 
> >>>   locale.cpp.o:(.gcc_except_table+0x70A) in archive /opt/llvm/lib/clang-runtimes/riscv64-unknown-elf/rv64imac/lp64/medany/lib/libc++.a


OK, please drop .eh_frame from the patch. I don't think a valid input can cause lld to choke. For .gcc_except_table, I still hope we can have a better understanding of the problem.
If it is indeed a larger issue like .eh_frame/ppc64 .toc/ppc32 .got2, we may have to work around it, but I want to make sure we are not working around a riscv toolchain problem.

If you can get a reproduce, I'd be happy help analyze it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83244





More information about the llvm-commits mailing list