[lld] r348468 - [ELF] - (-Map file) Implement printing of LMA for assignments outside of section declarations.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 6 01:04:53 PST 2018
Author: grimar
Date: Thu Dec 6 01:04:52 2018
New Revision: 348468
URL: http://llvm.org/viewvc/llvm-project?rev=348468&view=rev
Log:
[ELF] - (-Map file) Implement printing of LMA for assignments outside of section declarations.
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.
Differential revision: https://reviews.llvm.org/D45314
Modified:
lld/trunk/ELF/MapFile.cpp
lld/trunk/test/ELF/linkerscript/map-file.test
lld/trunk/test/ELF/linkerscript/map-file2.test
Modified: lld/trunk/ELF/MapFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.cpp?rev=348468&r1=348467&r2=348468&view=diff
==============================================================================
--- lld/trunk/ELF/MapFile.cpp (original)
+++ lld/trunk/ELF/MapFile.cpp Thu Dec 6 01:04:52 2018
@@ -163,17 +163,18 @@ void elf::writeMapFile() {
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';
Modified: lld/trunk/test/ELF/linkerscript/map-file.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/map-file.test?rev=348468&r1=348467&r2=348468&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/map-file.test (original)
+++ lld/trunk/test/ELF/linkerscript/map-file.test Thu Dec 6 01:04:52 2018
@@ -44,10 +44,10 @@ SECTIONS {
# 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
Modified: lld/trunk/test/ELF/linkerscript/map-file2.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/map-file2.test?rev=348468&r1=348467&r2=348468&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/map-file2.test (original)
+++ lld/trunk/test/ELF/linkerscript/map-file2.test Thu Dec 6 01:04:52 2018
@@ -8,6 +8,7 @@ SECTIONS {
.aaa : { *(.aaa.*) }
.bbb : AT(0x2000) { *(.bbb.*) }
.ccc : AT(0x3000) { *(.ccc.*) }
+ . += 0x100;
.ddd : {
BYTE(0x11)
. += 0x100;
@@ -24,16 +25,17 @@ SECTIONS {
# 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
More information about the llvm-commits
mailing list