[PATCH] D54495: [LLD] [COFF] Remove empty sections before calculating the size of section headers

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 13 14:44:01 PST 2018


pcc added a comment.

In https://reviews.llvm.org/D54495#1297657, @mstorsjo wrote:

> In https://reviews.llvm.org/D54495#1297650, @pcc wrote:
>
> > I don't understand this change, won't there always need to be an alignment gap of up to 512 bytes between sections? So it won't matter whether we align once or several times.
>
>
> Yes, but there is an alignment gap of 512 bytes more than necessary due to this.
>
> In one test of mine, SizeOfHeaders ends up as 1536 after alignment, based on an initial OutputSections.size() = 24. After removing the empty sections, I end up with OutputSections.size() = 15. If I have this value already when doing `assignAddresses`, the aligned SizeOfHeaders ends up as 1024. So it doesn't get rid of the gap altogether, but it makes sure it's not unnecessarily big.


Got it, it's due to the alignment gap between the section headers and the section contents, not the alignment between sections.

I think it should be possible to test this by providing an input file with a large number of empty sections and one non-empty section and checking the PointerToRawData value for the non-empty section.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D54495





More information about the llvm-commits mailing list