[PATCH] D74297: [ELF] Start a new PT_LOAD if LMA region is different
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 9 09:10:21 PST 2020
MaskRay created this revision.
MaskRay added reviewers: grimar, nickdesaulniers, peter.smith, ruiu, srhines.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
MaskRay added a parent revision: D74286: [ELF] Respect output section alignment for AT> (non-null lmaRegion).
GNU ld has a counterintuitive lang_propagate_lma_regions rule.
// .foo's LMA region is propagated to .bar because their VMA region is the same,
// and .bar does not have an explicit output section address (addr_tree).
.foo : { *(.foo) } >RAM AT> FLASH
.bar : { *(.bar) } >RAM
// An explicit output section address disables propagation.
.foo : { *(.foo) } >RAM AT> FLASH
.bar . : { *(.bar) } >RAM
In both cases, lld thinks .foo's LMA region is propagated and
places .bar in the same PT_LOAD, so lld diverges from GNU ld w.r.t. the
second case (lma-align.test).
This patch changes Writer<ELFT>::createPhdrs to disable propagation
(start a new PT_LOAD). A user of the first case can make linker scripts
portable by explicitly specifying `AT>`. By contrast, there was no
workaround for the old behavior.
This change uncovers another LMA related bug in assignOffsets() where
`ctx->lmaOffset = 0;` was omitted. It caused a spurious "load address
range overlaps" error for at2.test
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D74297
Files:
lld/ELF/LinkerScript.cpp
lld/ELF/Writer.cpp
lld/test/ELF/linkerscript/Inputs/at2.s
lld/test/ELF/linkerscript/at2.test
lld/test/ELF/linkerscript/at8.test
lld/test/ELF/linkerscript/lma-align.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74297.243450.patch
Type: text/x-patch
Size: 5558 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200209/2129bbd9/attachment.bin>
More information about the llvm-commits
mailing list