[PATCH] D76995: [ELF] Propagate LMA offset to sections with neither AT() nor AT>
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 30 10:16:59 PDT 2020
MaskRay added inline comments.
================
Comment at: lld/ELF/LinkerScript.cpp:866
+ ctx->lmaOffset = 0;
+ // Propagate ctx->lmaOffset to the first "non-header" section.
----------------
psmith wrote:
> At a glance, it looks like we might not handle this particular case, is this intentional?
> - If the section has a specific VMA address, then this is used as the LMA address as well.
> I think that this is where there is an addrExpr but no lmaExpr we should set ctx->lmaOffset = 0;
See below. This and `whereas GNU ld uses the previous OutputSections lma_region when address is not specified` need more thoughts.
================
Comment at: lld/docs/ELF/linker_script.rst:64
+ means the default region is used. Note, GNU ld propagates the previous LMA
+ memory region when ``address`` is not specified. The LMA is set to the
+ current location of the memory region aligned to the section alignment. In
----------------
psmith wrote:
> ```
> The lack of ``AT>lma_region``
> means the default region is used. Note, GNU ld propagates the previous LMA
> memory region when ``address`` is not specified.
> ```
> My understanding of the sentence is that when there is no AT > lma_region LLD does not behave like GNU ld. LLD always uses the default region, whereas GNU ld uses the previous OutputSections lma_region when address is not specified. If I'm right then is this an intentional change or a current limitation? I think we should be explicit, whichever way it is. For example:
>
> ```
> If the OutputSection has no ``AT>lma_region`` then LLD will always use the default memory region. Note that this is in contrast with GNU ld which will propagate the lma_region of the previous OutputSection when ``address`` is not specified. For a script that is compatible with
> GNU ld and LLD you must set ``AT>lma_region`` explicitly and not rely on propagation.
> whereas GNU ld uses the previous OutputSections lma_region when address is not specified.
Yes. See the summary of D74297. The patch was made when I did not have a good understanding of LMA (I still don't but things start to become clearer). We can revisit the decision and fix this discrepancy as well if not difficult to implement.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76995/new/
https://reviews.llvm.org/D76995
More information about the llvm-commits
mailing list