[PATCH] D45314: [ELF] - (-Map file) Implement printing of LMA for assignments outside of section declarations.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 03:45:59 PST 2018


grimar updated this revision to Diff 176788.
grimar added a comment.

- Rebased. Ping.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D45314/new/

https://reviews.llvm.org/D45314

Files:
  ELF/MapFile.cpp
  test/ELF/linkerscript/map-file.test
  test/ELF/linkerscript/map-file2.test


Index: test/ELF/linkerscript/map-file2.test
===================================================================
--- test/ELF/linkerscript/map-file2.test
+++ test/ELF/linkerscript/map-file2.test
@@ -8,6 +8,7 @@
   .aaa : { *(.aaa.*) }
   .bbb : AT(0x2000) { *(.bbb.*) }
   .ccc : AT(0x3000) { *(.ccc.*) }
+  . += 0x100;
   .ddd : {
     BYTE(0x11)
     . += 0x100;
@@ -24,16 +25,17 @@
 # CHECK-NEXT:       1008             2000        8     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.bbb)
 # CHECK-NEXT:       1010             3000        8     1 .ccc
 # CHECK-NEXT:       1010             3000        8     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.ccc)
-# CHECK-NEXT:       1018             3008      109     1 .ddd
-# CHECK-NEXT:       1018             3008        1     1         BYTE ( 0x11 )
-# CHECK-NEXT:       1019             3009      100     1         . += 0x100
-# CHECK-NEXT:       1119             3109        8     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.ddd)
-# CHECK-NEXT:       1128             3118       34     8 .eh_frame
-# CHECK-NEXT:       1128             3118       30     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.eh_frame+0x0)
-# CHECK-NEXT:       115c             314c        1     4 .text
-# CHECK-NEXT:       115c             314c        1     4         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.text)
-# CHECK-NEXT:       115c             314c        0     1                 f(int)
-# CHECK-NEXT:       115c             314c        0     1                 _start
+# CHECK-NEXT:       1018             3008      100     1 . += 0x100
+# CHECK-NEXT:       1118             3108      109     1 .ddd
+# CHECK-NEXT:       1118             3108        1     1         BYTE ( 0x11 )
+# CHECK-NEXT:       1119             3109      100     1         . += 0x100
+# CHECK-NEXT:       1219             3209        8     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.ddd)
+# CHECK-NEXT:       1228             3218       34     8 .eh_frame
+# CHECK-NEXT:       1228             3218       30     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.eh_frame+0x0)
+# CHECK-NEXT:       125c             324c        1     4 .text
+# CHECK-NEXT:       125c             324c        1     4         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.text)
+# CHECK-NEXT:       125c             324c        0     1                 f(int)
+# CHECK-NEXT:       125c             324c        0     1                 _start
 # CHECK-NEXT:          0                0        8     1 .comment
 # CHECK-NEXT:          0                0        8     1         <internal>:(.comment)
 # CHECK-NEXT:          0                0       48     8 .symtab
Index: test/ELF/linkerscript/map-file.test
===================================================================
--- test/ELF/linkerscript/map-file.test
+++ test/ELF/linkerscript/map-file.test
@@ -44,10 +44,10 @@
 # CHECK-NEXT:   2017             2017      246     1         . += 0x123 * ( 1 + 1 )
 # CHECK-NEXT:   225d             225d        0     1         foo = .
 # CHECK-NEXT:   225d             225d        0     1         bar = 0x42 - 0x26
-# CHECK-NEXT:   225d                0        0     1 sym1 = .
-# CHECK-NEXT:   225d                0      500     1 . += 0x500
-# CHECK-NEXT:   275d                0        0     1 sym2 = .
-# CHECK-NEXT:   275d                0        0     1 PROVIDE ( sym3 = 42 )
+# CHECK-NEXT:   225d             225d        0     1 sym1 = .
+# CHECK-NEXT:   225d             225d      500     1 . += 0x500
+# CHECK-NEXT:   275d             275d        0     1 sym2 = .
+# CHECK-NEXT:   275d             275d        0     1 PROVIDE ( sym3 = 42 )
 # CHECK-NEXT:   2760             2760       10     4 .text
 # CHECK-NEXT:   2760             2760       10     4         {{.*}}{{/|\\}}map-file.test.tmp.o:(.text)
 # CHECK-NEXT:      0                0        8     1 .comment
Index: ELF/MapFile.cpp
===================================================================
--- ELF/MapFile.cpp
+++ ELF/MapFile.cpp
@@ -163,17 +163,18 @@
   OS << right_justify("VMA", W) << ' ' << right_justify("LMA", W)
      << "     Size Align Out     In      Symbol\n";
 
+  OutputSection* OSec = nullptr;
   for (BaseCommand *Base : Script->SectionCommands) {
     if (auto *Cmd = dyn_cast<SymbolAssignment>(Base)) {
       if (Cmd->Provide && !Cmd->Sym)
         continue;
-      //FIXME: calculate and print LMA.
-      writeHeader(OS, Cmd->Addr, 0, Cmd->Size, 1);
+      uint64_t LMA = OSec ? OSec->getLMA() + Cmd->Addr - OSec->getVA(0) : 0;
+      writeHeader(OS, Cmd->Addr, LMA, Cmd->Size, 1);
       OS << Cmd->CommandString << '\n';
       continue;
     }
 
-    auto *OSec = cast<OutputSection>(Base);
+    OSec = cast<OutputSection>(Base);
     writeHeader(OS, OSec->Addr, OSec->getLMA(), OSec->Size, OSec->Alignment);
     OS << OSec->Name << '\n';
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45314.176788.patch
Type: text/x-patch
Size: 4822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181205/7d6b9dd9/attachment.bin>


More information about the llvm-commits mailing list