[PATCH] D38361: [ELF] Stop setting output section size early

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 07:45:19 PDT 2017


jhenderson created this revision.
Herald added subscribers: arichardson, sdardis.

This is an alternative to https://reviews.llvm.org/D38321. The motivation, as described in that patch, is the same:

> The size of an OutputSection is calculated early, to aid handling of compressed debug sections. However, subsequent to this point, unused synthetic sections are removed. In the event that an OutputSection, from which such an InputSection is removed, is still required (e.g. because it has a symbol assignment), and no longer has any InputSections, dot assignments, or BYTE()-family directives, the size member is never updated when processing the commands. If the removed InputSection had a non-zero size (such as a .got.plt section), the section ends up with the wrong size in the output.

In this version, I have stopped setting the OutputSection Size member and the InputSection OutSecOff member early. There were three issues I had to resolve, as a result of making this change:

1. Compressed debug sections still need the Size set early, because they are not processed in assignAddresses. The original behaviour of setting the size early is maintained for such sections.
2. The order of input sections is important for SHF_LINK_ORDER sections. This was previously relying on OutSecOff being an approximation for determining the final order. To avoid confusion, I have created a separate member variable that indicates what order the InputSection is within the OutputSection.
3. The MIPS GOT section requires the Size member to be set before it is finalized, but it needs to be finalized for the first time before assignAddresses is called, meaning the Size is not yet set. Instead, I have estimated the OutputSection size explicitly when requested. I am open to better suggestions on how to achieve this.


https://reviews.llvm.org/D38361

Files:
  ELF/InputSection.h
  ELF/OutputSections.cpp
  ELF/OutputSections.h
  ELF/SyntheticSections.cpp
  test/ELF/linkerscript/unused-synthetic.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38361.116981.patch
Type: text/x-patch
Size: 4951 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170928/daccd2b8/attachment.bin>


More information about the llvm-commits mailing list