summaryrefslogtreecommitdiff
path: root/lld/ELF/Writer.h
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2018-01-25 19:02:08 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2018-01-25 19:02:08 +0000
commit2d045a03ec64520f8c2003e573b686f5f1004e35 (patch)
tree9098d61f6257bb90129728259559ff74c4597f7a /lld/ELF/Writer.h
parentb0f3abba4631fab1a61ec55e0edb6f16dc01377a (diff)
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. I 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. I think the 3rd one is a hack for implementing per cpu data, but we can't break that.
Diffstat (limited to 'lld/ELF/Writer.h')
-rw-r--r--lld/ELF/Writer.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h
index d247068bab2..6875dc51403 100644
--- a/lld/ELF/Writer.h
+++ b/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();