[PATCH] D30832: [ELF] Fix LMA offset calculation

Eugene Leviant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 14 02:09:25 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL297713: [ELF] Fix LMA offset calculation (authored by evgeny777).

Changed prior to commit:
  https://reviews.llvm.org/D30832?vs=91356&id=91687#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30832

Files:
  lld/trunk/ELF/LinkerScript.cpp
  lld/trunk/test/ELF/linkerscript/at.s


Index: lld/trunk/test/ELF/linkerscript/at.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/at.s
+++ lld/trunk/test/ELF/linkerscript/at.s
@@ -18,6 +18,10 @@
 # RUN:  { \
 # RUN:   *(.ddd) \
 # RUN:  } \
+# RUN:  .eee 0x5000 : AT(0x5000) \
+# RUN:  { \
+# RUN:   *(.eee) \
+# RUN:  } \
 # RUN: }" > %t.script
 # RUN: ld.lld %t --script %t.script -o %t2
 # RUN: llvm-readobj -program-headers %t2 | FileCheck %s
@@ -79,6 +83,19 @@
 # CHECK-NEXT:     Offset: 0x1018
 # CHECK-NEXT:     VirtualAddress: 0x1018
 # CHECK-NEXT:     PhysicalAddress: 0x4000
+# CHECK-NEXT:     FileSize: 8
+# CHECK-NEXT:     MemSize: 8
+# CHECK-NEXT:     Flags [
+# CHECK-NEXT:       PF_R
+# CHECK-NEXT:       PF_X
+# CHECK-NEXT:     ]
+# CHECK-NEXT:     Alignment: 4096
+# CHECK-NEXT:   }
+# CHECK-NEXT:   ProgramHeader {
+# CHECK-NEXT:     Type: PT_LOAD
+# CHECK-NEXT:     Offset: 0x2000
+# CHECK-NEXT:     VirtualAddress: 0x5000
+# CHECK-NEXT:     PhysicalAddress: 0x5000
 # CHECK-NEXT:     FileSize: 9
 # CHECK-NEXT:     MemSize: 9
 # CHECK-NEXT:     Flags [
@@ -117,3 +134,6 @@
 
 .section .ddd, "a"
 .quad 0
+
+.section .eee, "a"
+.quad 0
Index: lld/trunk/ELF/LinkerScript.cpp
===================================================================
--- lld/trunk/ELF/LinkerScript.cpp
+++ lld/trunk/ELF/LinkerScript.cpp
@@ -547,17 +547,18 @@
 // for a single sections command (e.g. ".text { *(.text); }").
 template <class ELFT>
 void LinkerScript<ELFT>::assignOffsets(OutputSectionCommand *Cmd) {
-  if (Cmd->LMAExpr) {
-    uintX_t D = Dot;
-    LMAOffset = [=] { return Cmd->LMAExpr() - D; };
-  }
   OutputSection *Sec = findSection<ELFT>(Cmd->Name, *OutputSections);
   if (!Sec)
     return;
 
   if (Cmd->AddrExpr && Sec->Flags & SHF_ALLOC)
     setDot(Cmd->AddrExpr, Cmd->Location);
 
+  if (Cmd->LMAExpr) {
+    uintX_t D = Dot;
+    LMAOffset = [=] { return Cmd->LMAExpr() - D; };
+  }
+
   // Handle align (e.g. ".foo : ALIGN(16) { ... }").
   if (Cmd->AlignExpr)
     Sec->updateAlignment(Cmd->AlignExpr());


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30832.91687.patch
Type: text/x-patch
Size: 2049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170314/e11b08c2/attachment.bin>


More information about the llvm-commits mailing list