[ELF] Respect output section alignment for AT> (non-null lmaRegion)

Authored by MaskRay on Feb 8 2020, 11:07 AM.


[ELF] Respect output section alignment for AT> (non-null lmaRegion)

When lmaRegion is non-null, respect sec->alignment
This rule is analogous to switchTo(sec) which advances sh_addr (VMA).

This fixes the p_paddr misalignment issue as reported by

Note, sec->alignment is the maximum of ALIGN and input section alignments. We may overalign LMA than GNU ld.

linkerscript/align-lma.s has a FIXME that demonstrates another bug:
.bss ... >RAM should be placed in a different PT_LOAD (GNU ld
behavior) because its lmaRegion (nullptr) is different from the previous
section's lmaRegion (ROM).

Reviewed By: psmith

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