[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
Thu Apr 5 04:55:22 PDT 2018
grimar created this revision.
grimar added reviewers: ruiu, espindola.
Herald added subscribers: arichardson, emaste.
This was a missing piece.
We started to print LMAs and information about assignments,
but did not do that for assignments outside of section declarations yet.
The patch implements it.
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: 1124 3114 1 4 .text
-# CHECK-NEXT: 1124 3114 1 4 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.text)
-# CHECK-NEXT: 1124 3114 0 1 f(int)
-# CHECK-NEXT: 1124 3114 0 1 _start
-# CHECK-NEXT: 1128 3118 30 8 .eh_frame
-# CHECK-NEXT: 1128 3118 30 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.eh_frame+0x0)
+# 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: 1224 3214 1 4 .text
+# CHECK-NEXT: 1224 3214 1 4 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.text)
+# CHECK-NEXT: 1224 3214 0 1 f(int)
+# CHECK-NEXT: 1224 3214 0 1 _start
+# CHECK-NEXT: 1228 3218 30 8 .eh_frame
+# CHECK-NEXT: 1228 3218 30 1 {{.*}}{{/|\\}}map-file2.test.tmp.o:(.eh_frame+0x0)
# 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
@@ -175,19 +175,22 @@
OS << right_justify("VMA", W) << ' ' << right_justify("LMA", 9) << ' '
<< right_justify("Size", W) << " Align Out In Symbol\n";
+ OutputSection* LastOS = 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 =
+ LastOS ? LastOS->getLMA() + Cmd->Addr - LastOS->getVA(0) : 0;
+ writeHeader(OS, Cmd->Addr, LMA, Cmd->Size, 1);
OS << Cmd->CommandString << '\n';
continue;
}
auto *OSec = dyn_cast<OutputSection>(Base);
if (!OSec)
continue;
+ LastOS = OSec;
writeHeader(OS, OSec->Addr, OSec->getLMA(), OSec->Size, OSec->Alignment);
OS << OSec->Name << '\n';
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45314.141128.patch
Type: text/x-patch
Size: 4926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180405/7869cba9/attachment.bin>
More information about the llvm-commits
mailing list