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

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 13 13:53:36 PST 2018


mstorsjo added a comment.

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.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D54495





More information about the llvm-commits mailing list