[PATCH] D59216: [LLD][ELF][ARM] Redesign of .ARM.exidx handling to use a SyntheticSection

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 10:24:59 PDT 2019


peter.smith updated this revision to Diff 192132.
peter.smith added a comment.

In D59216#1439647 <https://reviews.llvm.org/D59216#1439647>, @peter.smith wrote:

> I've discovered 3 problems with this, the first 2 are trivial to fix, the last is not so I think I'll need to send for review when I've fixed rather than just recommit. The trivial problems are:
>
> - When all the .ARM.exidx sections from input files are merged into a synthetic one the getLinkOrderDep() function can't find any .ARM.exidx section and returns nullptr.
>   - 1 line fix to just return the front() of the ExecutableSections vector, as that will always exist.
> - If the In.ARMexidx is discarded via \DISCARD\ then scanning its relocations adds a dependency to the personality routine (undefined symbol error).
>   - 1 line fix to skip the relocation scanning if In.ARM.exidx is not live.
>
>     The difficult problem to fix is that --emit-relocs doesn't work with the SyntheticSection.
> - The .ARM.exidx InputSections have been removed so there is no way to get the OutputSection
> - If table merging is on then we end up with spurious relocations for the removed table. This is true of the existing implementation.
>
>   I'm investigating the best way of fixing this. The approach I'm currently favouring is following the example of EhInputSection. The alternative is some special cases for .ARM.exidx, I think that these could prove fragile so I'm tending towards the former even if it is more code.


Updated diff with proposed fixes for the three problems found. As mentioned above the first two changes are trivial, I think the last should be looked at in case of disagreement. There are 3 problems caused by --emit-relocs:

- The relocation sections for the .ARM.exidx sections need to find the In.ARMExidx to find their OutputSection in an anlagous way to the EHInputSections need to find the In.EhFrame section.
- The merging of duplicate entries will result in removed .ARM.exidx sections, with --emit-relocs we'll need to remove the associated .rel.ARM.exidx section
- There are no .rel.ARM.exidx sections for linker created table entries.

I've fixed the first two parts with this diff. I don't think that there is an easy fix for --emit-relocs and linker created table entries. I'm not too worried about that as I don't think we do so for other synthetic sections like PLT entries. I'll add some comments to highlight the changes.


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

https://reviews.llvm.org/D59216

Files:
  ELF/InputSection.cpp
  ELF/OutputSections.cpp
  ELF/SyntheticSections.cpp
  ELF/SyntheticSections.h
  ELF/Writer.cpp
  test/ELF/arm-data-prel.s
  test/ELF/arm-exidx-add-missing.s
  test/ELF/arm-exidx-canunwind.s
  test/ELF/arm-exidx-dedup.s
  test/ELF/arm-exidx-discard.s
  test/ELF/arm-exidx-emit-relocs.s
  test/ELF/arm-exidx-gc.s
  test/ELF/arm-exidx-no-add-missing.s
  test/ELF/arm-exidx-shared.s
  test/ELF/arm-exidx-synthetic-link.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59216.192132.patch
Type: text/x-patch
Size: 38645 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190325/89eac170/attachment.bin>


More information about the llvm-commits mailing list