mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-17 10:26:15 +00:00
lld: Move LMAOffset from the OutputSection to the PhdrEntry. NFC.
If two sections are in the same PT_LOAD, their relatives offsets, virtual address and physical addresses are all the same. [Rafael] initially wanted to have a single global LMAOffset, on the assumption that every ELF file was in practiced loaded contiguously in both physical and virtual memory. Unfortunately that is not the case. The linux kernel has: LOAD 0x200000 0xffffffff81000000 0x0000000001000000 0xced000 0xced000 R E 0x200000 LOAD 0x1000000 0xffffffff81e00000 0x0000000001e00000 0x15f000 0x15f000 RW 0x200000 LOAD 0x1200000 0x0000000000000000 0x0000000001f5f000 0x01b198 0x01b198 RW 0x200000 LOAD 0x137b000 0xffffffff81f7b000 0x0000000001f7b000 0x116000 0x1ec000 RWE 0x200000 The delta for all but the third PT_LOAD is the same: 0xffffffff80000000. [Rafael] thinks the 3rd one is a hack for implementing per cpu data, but we can't break that. Obtained from: LLVM r323456 by Rafael Espindola
This commit is contained in:
parent
2b8c81f1b9
commit
1da0355521
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=328547
@ -671,8 +671,8 @@ void LinkerScript::assignOffsets(OutputSection *Sec) {
|
||||
// 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
|
||||
if (Ctx->LMAOffset)
|
||||
Ctx->OutSec->LMAOffset = Ctx->LMAOffset;
|
||||
if (PhdrEntry *L = Ctx->OutSec->PtLoad)
|
||||
L->LMAOffset = Ctx->LMAOffset;
|
||||
|
||||
// The Size previously denoted how many InputSections had been added to this
|
||||
// section, and was used for sorting SHF_LINK_ORDER sections. Reset it to
|
||||
|
@ -49,7 +49,7 @@ class OutputSection final : public BaseCommand, public SectionBase {
|
||||
|
||||
static bool classof(const BaseCommand *C);
|
||||
|
||||
uint64_t getLMA() const { return Addr + LMAOffset; }
|
||||
uint64_t getLMA() const { return PtLoad ? Addr + PtLoad->LMAOffset : Addr; }
|
||||
template <typename ELFT> void writeHeaderTo(typename ELFT::Shdr *SHdr);
|
||||
|
||||
unsigned SectionIndex;
|
||||
@ -78,7 +78,6 @@ class OutputSection final : public BaseCommand, public SectionBase {
|
||||
|
||||
// The following fields correspond to Elf_Shdr members.
|
||||
uint64_t Offset = 0;
|
||||
uint64_t LMAOffset = 0;
|
||||
uint64_t Addr = 0;
|
||||
uint32_t ShName = 0;
|
||||
|
||||
|
@ -44,6 +44,7 @@ struct PhdrEntry {
|
||||
OutputSection *FirstSec = nullptr;
|
||||
OutputSection *LastSec = nullptr;
|
||||
bool HasLMA = false;
|
||||
uint64_t LMAOffset = 0;
|
||||
};
|
||||
|
||||
void addReservedSymbols();
|
||||
|
Loading…
Reference in New Issue
Block a user