HomePhabricator

[ELF] Ignore the maximum of input section alignments for two cases

Authored by MaskRay on Feb 17 2020, 10:21 AM.

Description

[ELF] Ignore the maximum of input section alignments for two cases

Follow-up for D74286.

Notations:

  • alignExpr: the computed ALIGN value
  • max_input_align: the maximum of input section alignments

This patch changes the following two cases to match GNU ld:

  • When ALIGN is present, GNU ld sets output sh_addr to alignExpr, while lld use max(alignExpr, max_input_align)
  • When addrExpr is specified but alignExpr is not, GNU ld sets output sh_addr to addrExpr, while lld uses advance(0, max_input_align)

Note, sh_addralign is still set to max(alignExpr, max_input_align).

lma-align.test is enhanced a bit to check we don't overalign sh_addr.

fixSectionAlignments() sets addrExpr but not alignExpr for the !hasSectionsCommand case.
This patch sets alignExpr as well so that max_input_align will be respected.

Reviewed By: grimar

Differential Revision: https://reviews.llvm.org/D74736

Details

Committed
MaskRayFeb 21 2020, 8:12 AM
Reviewer
grimar
Differential Revision
D74736: [ELF] Ignore the maximum of input section alignments for two cases
Parents
rG89dc8fe62220: AMDGPU/GlobalISel: Precommit xnor matching test
Branches
Unknown
Tags
Unknown