[PATCH] D30163: [ELF] - Postpone evaluation of LMA offset.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 21 07:01:48 PST 2017
George Rimar <grimar at accesssoftek.com> writes:
>>This is a bit confusing. Why do we need to hold information in
>>LinkerScript.h? OutputSectionCommand *Cmd holds the expression, can't we
>>just evaluate it once the virtual addresses are computed?
>
> I think we can't. Testcase at.s shows why:
> .aaa : AT(0x2000) { *(.aaa) }
> .bbb : { *(.bbb) }
>
> In that case we should do:
> // If neither AT nor AT> is specified for an allocatable section, the linker
> // will set the LMA such that the difference between VMA and LMA for the
> // section is the same as the preceding output section in the same region
> // https://sourceware.org/binutils/docs-2.20/ld/Output-Section-LMA.html
>
> We calculate LMA as:
> uint64_t getLMA() const { return Addr + LMAOffset; }
>
> So VA(.bbb) - VA(.aaa) == LMA(.bbb) - LMA(.aaa).
>
> And at the moment of computing VA for .bbb its command
> does not have LMA expression. (We only have it for .aaa).
>
> We also create phdrs later, so do not know FirstInPtLoad at this moment,
> so I think we can't find first output section in the current load to take
> its LMA offset at this step too.
I see. Taking another look.
Thanks,
Rafael
More information about the llvm-commits
mailing list