aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2018-01-29 13:54:51 +0000
committerEd Maste <emaste@FreeBSD.org>2018-01-29 13:54:51 +0000
commit1da03555210ed6ec24640f491949bec9b114f080 (patch)
tree39fd4ea88cc39f2714ed0f16246e60b5fcdb3fd4 /contrib
parent2b8c81f1b9be358776b8f5aa811fd2e834a6f152 (diff)
downloadsrc-1da03555210ed6ec24640f491949bec9b114f080.tar.gz
src-1da03555210ed6ec24640f491949bec9b114f080.zip
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
Notes
Notes: svn path=/head/; revision=328547
Diffstat (limited to 'contrib')
-rw-r--r--contrib/llvm/tools/lld/ELF/LinkerScript.cpp4
-rw-r--r--contrib/llvm/tools/lld/ELF/OutputSections.h3
-rw-r--r--contrib/llvm/tools/lld/ELF/Writer.h1
3 files changed, 4 insertions, 4 deletions
diff --git a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
index 20566995ad30..23c3a11a9d1d 100644
--- a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
+++ b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
@@ -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
diff --git a/contrib/llvm/tools/lld/ELF/OutputSections.h b/contrib/llvm/tools/lld/ELF/OutputSections.h
index dd7f0955c986..c006eae0c04b 100644
--- a/contrib/llvm/tools/lld/ELF/OutputSections.h
+++ b/contrib/llvm/tools/lld/ELF/OutputSections.h
@@ -49,7 +49,7 @@ public:
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 @@ public:
// The following fields correspond to Elf_Shdr members.
uint64_t Offset = 0;
- uint64_t LMAOffset = 0;
uint64_t Addr = 0;
uint32_t ShName = 0;
diff --git a/contrib/llvm/tools/lld/ELF/Writer.h b/contrib/llvm/tools/lld/ELF/Writer.h
index d247068bab23..6875dc514039 100644
--- a/contrib/llvm/tools/lld/ELF/Writer.h
+++ b/contrib/llvm/tools/lld/ELF/Writer.h
@@ -44,6 +44,7 @@ struct PhdrEntry {
OutputSection *FirstSec = nullptr;
OutputSection *LastSec = nullptr;
bool HasLMA = false;
+ uint64_t LMAOffset = 0;
};
void addReservedSymbols();