[lld] r329312 - Fix column size in the map file.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 5 09:45:37 PDT 2018


Author: ruiu
Date: Thu Apr  5 09:45:37 2018
New Revision: 329312

URL: http://llvm.org/viewvc/llvm-project?rev=329312&view=rev
Log:
Fix column size in the map file.

Size can be narrow, but LMA should be the same width as VMA.

Modified:
    lld/trunk/ELF/MapFile.cpp
    lld/trunk/test/ELF/linkerscript/map-file.test
    lld/trunk/test/ELF/linkerscript/map-file2.test
    lld/trunk/test/ELF/map-file.s

Modified: lld/trunk/ELF/MapFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MapFile.cpp?rev=329312&r1=329311&r2=329312&view=diff
==============================================================================
--- lld/trunk/ELF/MapFile.cpp (original)
+++ lld/trunk/ELF/MapFile.cpp Thu Apr  5 09:45:37 2018
@@ -46,8 +46,10 @@ static const std::string Indent16 = "
 // Print out the first three columns of a line.
 static void writeHeader(raw_ostream &OS, uint64_t VMA, uint64_t LMA,
                         uint64_t Size, uint64_t Align) {
-  int W = Config->Is64 ? 16 : 8;
-  OS << format("%*llx %9llx %*llx %5lld ", W, VMA, LMA, W, Size, Align);
+  if (Config->Is64)
+    OS << format("%16llx %16llx %9llx %5lld ", VMA, LMA, Size, Align);
+  else
+    OS << format("%8llx %8llx %9llx %5lld ", VMA, LMA, Size, Align);
 }
 
 // Returns a list of all symbols that we want to print out.
@@ -172,8 +174,8 @@ void elf::writeMapFile() {
 
   // Print out the header line.
   int W = Config->Is64 ? 16 : 8;
-  OS << right_justify("VMA", W) << ' ' << right_justify("LMA", 9) << ' '
-     << right_justify("Size", W) << " Align Out     In      Symbol\n";
+  OS << right_justify("VMA", W) << ' ' << right_justify("LMA", W) << ' '
+     << right_justify("Size", 9) << " Align Out     In      Symbol\n";
 
   for (BaseCommand *Base : Script->SectionCommands) {
     if (auto *Cmd = dyn_cast<SymbolAssignment>(Base)) {

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=329312&r1=329311&r2=329312&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/map-file.test (original)
+++ lld/trunk/test/ELF/linkerscript/map-file.test Thu Apr  5 09:45:37 2018
@@ -30,31 +30,31 @@ SECTIONS {
   PROVIDE(sym3 = 42);
 }
 
-# CHECK:         VMA       LMA             Size Align Out     In      Symbol
-# CHECK-NEXT:      0         0             1000     1 . = 0x1000
-# CHECK-NEXT:   1000      1000             125d     1 .foo
-# CHECK-NEXT:   1000      1000                1     1         BYTE ( 0x11 )
-# CHECK-NEXT:   1001      1001                2     1         SHORT ( 0x1122 )
-# CHECK-NEXT:   1003      1003                4     1         LONG ( 0x11223344 )
-# CHECK-NEXT:   1007      1007                8     1         QUAD ( 0x1122334455667788 )
-# CHECK-NEXT:   100f      100f                0     1         PROVIDE_HIDDEN ( sym4 = . )
-# CHECK-NEXT:   100f      100f             1000     1         . += 0x1000
-# CHECK-NEXT:   200f      200f                8     1         {{.*}}{{/|\\}}map-file.test.tmp.o:(.foo.1)
-# CHECK-NEXT:   2017      2017                0     1         HIDDEN ( sym6 = . )
-# 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:   2760      2760               10     4 .text
-# CHECK-NEXT:   2760      2760               10     4         {{.*}}{{/|\\}}map-file.test.tmp.o:(.text)
-# CHECK-NEXT:      0         0                8     1 .comment
-# CHECK-NEXT:      0         0                8     1         <internal>:(.comment)
-# CHECK-NEXT:      0         0               c0     8 .symtab
-# CHECK-NEXT:      0         0               c0     8         <internal>:(.symtab)
-# CHECK-NEXT:      0         0               2f     1 .shstrtab
-# CHECK-NEXT:      0         0               2f     1         <internal>:(.shstrtab)
-# CHECK-NEXT:      0         0               22     1 .strtab
-# CHECK-NEXT:      0         0               22     1         <internal>:(.strtab)
+# CHECK:         VMA              LMA      Size Align Out     In      Symbol
+# CHECK-NEXT:      0                0      1000     1 . = 0x1000
+# CHECK-NEXT:   1000             1000      125d     1 .foo
+# CHECK-NEXT:   1000             1000         1     1         BYTE ( 0x11 )
+# CHECK-NEXT:   1001             1001         2     1         SHORT ( 0x1122 )
+# CHECK-NEXT:   1003             1003         4     1         LONG ( 0x11223344 )
+# CHECK-NEXT:   1007             1007         8     1         QUAD ( 0x1122334455667788 )
+# CHECK-NEXT:   100f             100f         0     1         PROVIDE_HIDDEN ( sym4 = . )
+# CHECK-NEXT:   100f             100f      1000     1         . += 0x1000
+# CHECK-NEXT:   200f             200f         8     1         {{.*}}{{/|\\}}map-file.test.tmp.o:(.foo.1)
+# CHECK-NEXT:   2017             2017         0     1         HIDDEN ( sym6 = . )
+# 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:   2760             2760        10     4 .text
+# CHECK-NEXT:   2760             2760        10     4         {{.*}}{{/|\\}}map-file.test.tmp.o:(.text)
+# CHECK-NEXT:      0                0         8     1 .comment
+# CHECK-NEXT:      0                0         8     1         <internal>:(.comment)
+# CHECK-NEXT:      0                0        c0     8 .symtab
+# CHECK-NEXT:      0                0        c0     8         <internal>:(.symtab)
+# CHECK-NEXT:      0                0        2f     1 .shstrtab
+# CHECK-NEXT:      0                0        2f     1         <internal>:(.shstrtab)
+# CHECK-NEXT:      0                0        22     1 .strtab
+# CHECK-NEXT:      0                0        22     1         <internal>:(.strtab)

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=329312&r1=329311&r2=329312&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/map-file2.test (original)
+++ lld/trunk/test/ELF/linkerscript/map-file2.test Thu Apr  5 09:45:37 2018
@@ -16,29 +16,29 @@ SECTIONS {
   .text : { *(.text.*) }
 }
 
-# CHECK:             VMA       LMA             Size Align Out     In      Symbol
-# CHECK-NEXT:          0         0             1000     1 . = 0x1000
-# CHECK-NEXT:       1000      1000                8     1 .aaa
-# CHECK-NEXT:       1000      1000                8     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.aaa)
-# CHECK-NEXT:       1008      2000                8     1 .bbb
-# 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:          0         0                8     1 .comment
-# CHECK-NEXT:          0         0                8     1         <internal>:(.comment)
-# CHECK-NEXT:          0         0               48     8 .symtab
-# CHECK-NEXT:          0         0               48     8         <internal>:(.symtab)
-# CHECK-NEXT:          0         0               48     1 .shstrtab
-# CHECK-NEXT:          0         0               48     1         <internal>:(.shstrtab)
-# CHECK-NEXT:          0         0                e     1 .strtab
-# CHECK-NEXT:          0         0                e     1         <internal>:(.strtab)
+# CHECK:             VMA              LMA      Size Align Out     In      Symbol
+# CHECK-NEXT:          0                0      1000     1 . = 0x1000
+# CHECK-NEXT:       1000             1000         8     1 .aaa
+# CHECK-NEXT:       1000             1000         8     1         {{.*}}{{/|\\}}map-file2.test.tmp.o:(.aaa)
+# CHECK-NEXT:       1008             2000         8     1 .bbb
+# 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:          0                0         8     1 .comment
+# CHECK-NEXT:          0                0         8     1         <internal>:(.comment)
+# CHECK-NEXT:          0                0        48     8 .symtab
+# CHECK-NEXT:          0                0        48     8         <internal>:(.symtab)
+# CHECK-NEXT:          0                0        48     1 .shstrtab
+# CHECK-NEXT:          0                0        48     1         <internal>:(.shstrtab)
+# CHECK-NEXT:          0                0         e     1 .strtab
+# CHECK-NEXT:          0                0         e     1         <internal>:(.strtab)

Modified: lld/trunk/test/ELF/map-file.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/map-file.s?rev=329312&r1=329311&r2=329312&view=diff
==============================================================================
--- lld/trunk/test/ELF/map-file.s (original)
+++ lld/trunk/test/ELF/map-file.s Thu Apr  5 09:45:37 2018
@@ -40,60 +40,60 @@ local:
 abs = 0xAB5
 labs = 0x1AB5
 
-// CHECK:         VMA       LMA             Size Align Out     In      Symbol
-// CHECK-NEXT: 2001c8    2001c8               78     8 .dynsym
-// CHECK-NEXT: 2001c8    2001c8               78     8         <internal>:(.dynsym)
-// CHECK-NEXT: 200240    200240               2c     8 .gnu.hash
-// CHECK-NEXT: 200240    200240               2c     8         <internal>:(.gnu.hash)
-// CHECK-NEXT: 20026c    20026c               30     4 .hash
-// CHECK-NEXT: 20026c    20026c               30     4         <internal>:(.hash)
-// CHECK-NEXT: 20029c    20029c               31     1 .dynstr
-// CHECK-NEXT: 20029c    20029c               31     1         <internal>:(.dynstr)
-// CHECK-NEXT: 2002d0    2002d0               30     8 .rela.dyn
-// CHECK-NEXT: 2002d0    2002d0               30     8         <internal>:(.rela.dyn)
-// CHECK-NEXT: 200300    200300               30     8 .rela.plt
-// CHECK-NEXT: 200300    200300               30     8         <internal>:(.rela.plt)
-// CHECK-NEXT: 200330    200330               60     8 .eh_frame
-// CHECK-NEXT: 200330    200330               2c     1         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x0)
-// CHECK-NEXT: 200360    200360               14     1         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x2c)
-// CHECK-NEXT: 200378    200378               18     1         {{.*}}{{/|\\}}map-file.s.tmp2.o:(.eh_frame+0x18)
-// CHECK-NEXT: 201000    201000               2d     4 .text
-// CHECK-NEXT: 201000    201000               28     4         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text)
-// CHECK-NEXT: 201000    201000                0     1                 _start
-// CHECK-NEXT: 20101f    20101f                0     1                 f(int)
-// CHECK-NEXT: 201028    201028                0     1                 local
-// CHECK-NEXT: 201028    201028                2     4         {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text)
-// CHECK-NEXT: 201028    201028                0     1                 foo
-// CHECK-NEXT: 201029    201029                0     1                 bar
-// CHECK-NEXT: 20102a    20102a                0     1         {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text.zed)
-// CHECK-NEXT: 20102a    20102a                0     1                 zed
-// CHECK-NEXT: 20102c    20102c                0     4         {{.*}}{{/|\\}}map-file.s.tmp3.o:(.text)
-// CHECK-NEXT: 20102c    20102c                0     1                 bah
-// CHECK-NEXT: 20102c    20102c                1     4         {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o):(.text)
-// CHECK-NEXT: 20102c    20102c                0     1                 baz
-// CHECK-NEXT: 201030    201030               30    16 .plt
-// CHECK-NEXT: 201030    201030               30    16         <internal>:(.plt)
-// CHECK-NEXT: 201040         0                0     1                 sharedFunc1
-// CHECK-NEXT: 201050         0                0     1                 sharedFunc2
-// CHECK-NEXT: 202000    202000               28     8 .got.plt
-// CHECK-NEXT: 202000    202000               28     8         <internal>:(.got.plt)
-// CHECK-NEXT: 203000    203000              100     8 .dynamic
-// CHECK-NEXT: 203000    203000              100     8         <internal>:(.dynamic)
-// CHECK-NEXT: 204000    204000               10    16 .bss
-// CHECK-NEXT: 204000    204000                4    16         {{.*}}{{/|\\}}map-file.s.tmp1.o:(COMMON)
-// CHECK-NEXT: 204000    204000                4     1                 common
-// CHECK-NEXT: 204004    204004                4     1         <internal>:(.bss)
-// CHECK-NEXT: 204004    204004                4     1                 sharedFoo
-// CHECK-NEXT: 204008    204008                8     1         <internal>:(.bss)
-// CHECK-NEXT: 204008    204008                8     1                 sharedBar
-// CHECK-NEXT:      0         0                8     1 .comment
-// CHECK-NEXT:      0         0                8     1         <internal>:(.comment)
-// CHECK-NEXT:      0         0              198     8 .symtab
-// CHECK-NEXT:      0         0              198     8         <internal>:(.symtab)
-// CHECK-NEXT:      0         0               84     1 .shstrtab
-// CHECK-NEXT:      0         0               84     1         <internal>:(.shstrtab)
-// CHECK-NEXT:      0         0               6d     1 .strtab
-// CHECK-NEXT:      0         0               6d     1         <internal>:(.strtab)
+// CHECK:         VMA              LMA      Size Align Out     In      Symbol
+// CHECK-NEXT: 2001c8           2001c8        78     8 .dynsym
+// CHECK-NEXT: 2001c8           2001c8        78     8         <internal>:(.dynsym)
+// CHECK-NEXT: 200240           200240        2c     8 .gnu.hash
+// CHECK-NEXT: 200240           200240        2c     8         <internal>:(.gnu.hash)
+// CHECK-NEXT: 20026c           20026c        30     4 .hash
+// CHECK-NEXT: 20026c           20026c        30     4         <internal>:(.hash)
+// CHECK-NEXT: 20029c           20029c        31     1 .dynstr
+// CHECK-NEXT: 20029c           20029c        31     1         <internal>:(.dynstr)
+// CHECK-NEXT: 2002d0           2002d0        30     8 .rela.dyn
+// CHECK-NEXT: 2002d0           2002d0        30     8         <internal>:(.rela.dyn)
+// CHECK-NEXT: 200300           200300        30     8 .rela.plt
+// CHECK-NEXT: 200300           200300        30     8         <internal>:(.rela.plt)
+// CHECK-NEXT: 200330           200330        60     8 .eh_frame
+// CHECK-NEXT: 200330           200330        2c     1         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x0)
+// CHECK-NEXT: 200360           200360        14     1         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.eh_frame+0x2c)
+// CHECK-NEXT: 200378           200378        18     1         {{.*}}{{/|\\}}map-file.s.tmp2.o:(.eh_frame+0x18)
+// CHECK-NEXT: 201000           201000        2d     4 .text
+// CHECK-NEXT: 201000           201000        28     4         {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text)
+// CHECK-NEXT: 201000           201000         0     1                 _start
+// CHECK-NEXT: 20101f           20101f         0     1                 f(int)
+// CHECK-NEXT: 201028           201028         0     1                 local
+// CHECK-NEXT: 201028           201028         2     4         {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text)
+// CHECK-NEXT: 201028           201028         0     1                 foo
+// CHECK-NEXT: 201029           201029         0     1                 bar
+// CHECK-NEXT: 20102a           20102a         0     1         {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text.zed)
+// CHECK-NEXT: 20102a           20102a         0     1                 zed
+// CHECK-NEXT: 20102c           20102c         0     4         {{.*}}{{/|\\}}map-file.s.tmp3.o:(.text)
+// CHECK-NEXT: 20102c           20102c         0     1                 bah
+// CHECK-NEXT: 20102c           20102c         1     4         {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o):(.text)
+// CHECK-NEXT: 20102c           20102c         0     1                 baz
+// CHECK-NEXT: 201030           201030        30    16 .plt
+// CHECK-NEXT: 201030           201030        30    16         <internal>:(.plt)
+// CHECK-NEXT: 201040                0         0     1                 sharedFunc1
+// CHECK-NEXT: 201050                0         0     1                 sharedFunc2
+// CHECK-NEXT: 202000           202000        28     8 .got.plt
+// CHECK-NEXT: 202000           202000        28     8         <internal>:(.got.plt)
+// CHECK-NEXT: 203000           203000       100     8 .dynamic
+// CHECK-NEXT: 203000           203000       100     8         <internal>:(.dynamic)
+// CHECK-NEXT: 204000           204000        10    16 .bss
+// CHECK-NEXT: 204000           204000         4    16         {{.*}}{{/|\\}}map-file.s.tmp1.o:(COMMON)
+// CHECK-NEXT: 204000           204000         4     1                 common
+// CHECK-NEXT: 204004           204004         4     1         <internal>:(.bss)
+// CHECK-NEXT: 204004           204004         4     1                 sharedFoo
+// CHECK-NEXT: 204008           204008         8     1         <internal>:(.bss)
+// CHECK-NEXT: 204008           204008         8     1                 sharedBar
+// CHECK-NEXT:      0                0         8     1 .comment
+// CHECK-NEXT:      0                0         8     1         <internal>:(.comment)
+// CHECK-NEXT:      0                0       198     8 .symtab
+// CHECK-NEXT:      0                0       198     8         <internal>:(.symtab)
+// CHECK-NEXT:      0                0        84     1 .shstrtab
+// CHECK-NEXT:      0                0        84     1         <internal>:(.shstrtab)
+// CHECK-NEXT:      0                0        6d     1 .strtab
+// CHECK-NEXT:      0                0        6d     1         <internal>:(.strtab)
 
 // RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \
 // RUN:  | FileCheck -check-prefix=FAIL %s




More information about the llvm-commits mailing list