[PATCH] D61296: [ELF] Place SHT_NOTE sections with the same alignment into one PT_NOTE

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 17:27:59 PDT 2019


MaskRay added a comment.

In D61296#1484755 <https://reviews.llvm.org/D61296#1484755>, @jakehehrlich wrote:

> If multiple note sections with unaligned sizes but larger than 4-byte alignment are used this solution doesn't work.


I've mentioned this in the description.
First, alignments other than 4/8 are unrealistic.
Second, `sh_size%sh_addralign!=0` is unrealistic. The rule for linking unrecognized sections is (linker doesn't know the semantics of many `.note*`):

> Unrecognized sections that do not have the SHF_OS_NONCONFORMING attribute, are combined in a two-phase process. As the link editor combines sections using this process, it must honor the alignment constraints of the input sections (asserted by the sh_addralign field), padding between sections with zero bytes, if necessary, and producing a combination with the maximum alignment constraint of its component input sections.

Say you have a `.note.a` (`sh_addralign=8 sh_size=9`) followed by another `.note.a` (`sh_addralign=8 sh_size=16`). The size of the first note is not a multiple of the alignment. The linker will emit a 7-byte padding (as if ``sh_addralign=8 sh_size=9+7`). To guarantee the notes after linking are parsable, the compilers must take into account of this factor and emit size aligned notes to the object files.


Repository:
  rLLD LLVM Linker

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

https://reviews.llvm.org/D61296





More information about the llvm-commits mailing list