[PATCH] D37469: [ELF] - Linkerscript: set load address correctly if MEMORY command used.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 02:39:04 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL312625: [ELF] - Linkerscript: set load address correctly if MEMORY command used. (authored by grimar).
Changed prior to commit:
https://reviews.llvm.org/D37469?vs=113840&id=113973#toc
Repository:
rL LLVM
https://reviews.llvm.org/D37469
Files:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/memory-at.s
Index: lld/trunk/test/ELF/linkerscript/memory-at.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/memory-at.s
+++ lld/trunk/test/ELF/linkerscript/memory-at.s
@@ -0,0 +1,46 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+# RUN: echo "MEMORY { \
+# RUN: FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0x100 \
+# RUN: RAM (rwx) : ORIGIN = 0x2000, LENGTH = 0x100 } \
+# RUN: SECTIONS { \
+# RUN: .text : { *(.text*) } > FLASH \
+# RUN: __etext = .; \
+# RUN: .data : AT (__etext) { *(.data*) } > RAM \
+# RUN: }" > %t.script
+# RUN: ld.lld %t --script %t.script -o %t2
+# RUN: llvm-readobj -program-headers %t2 | FileCheck %s
+
+# CHECK: ProgramHeaders [
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x1000
+# CHECK-NEXT: VirtualAddress: 0x1000
+# CHECK-NEXT: PhysicalAddress: 0x1000
+# CHECK-NEXT: FileSize: 8
+# CHECK-NEXT: MemSize: 8
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_X
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment:
+# CHECK-NEXT: }
+# CHECK-NEXT: ProgramHeader {
+# CHECK-NEXT: Type: PT_LOAD
+# CHECK-NEXT: Offset: 0x2000
+# CHECK-NEXT: VirtualAddress: 0x2000
+# CHECK-NEXT: PhysicalAddress: 0x1008
+# CHECK-NEXT: FileSize: 8
+# CHECK-NEXT: MemSize: 8
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: PF_R
+# CHECK-NEXT: PF_W
+# CHECK-NEXT: ]
+# CHECK-NEXT: Alignment:
+# CHECK-NEXT: }
+
+.section .text, "ax"
+.quad 0
+
+.section .data, "aw"
+.quad 0
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -616,14 +616,15 @@
else if (Sec->AddrExpr)
setDot(Sec->AddrExpr, Sec->Location, false);
+ CurAddressState->MemRegion = Sec->MemRegion;
+ if (CurAddressState->MemRegion)
+ Dot = CurAddressState->MemRegionOffset[CurAddressState->MemRegion];
+
if (Sec->LMAExpr) {
uint64_t D = Dot;
CurAddressState->LMAOffset = [=] { return Sec->LMAExpr().getValue() - D; };
}
- CurAddressState->MemRegion = Sec->MemRegion;
- if (CurAddressState->MemRegion)
- Dot = CurAddressState->MemRegionOffset[CurAddressState->MemRegion];
switchTo(Sec);
// We do not support custom layout for compressed debug sectons.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37469.113973.patch
Type: text/x-patch
Size: 2557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170906/35f6db4a/attachment.bin>
More information about the llvm-commits
mailing list