[llvm-readelf] --notes: move 'Data size' column left by 1
authorFangrui Song <maskray@google.com>
Wed, 7 Aug 2019 09:13:11 +0000 (09:13 +0000)
committerFangrui Song <maskray@google.com>
Wed, 7 Aug 2019 09:13:11 +0000 (09:13 +0000)
readelf -n:

```
// "Data size" is not left justified
  Owner                 Data size       Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
```

llvm-readelf -n (before):
```
// "Data size" column shifted by 1
  Owner                 Data size        Description
  GNU                   0x00000010       NT_GNU_ABI_TAG (ABI version tag)
```

llvm-readelf -n (after):
```
  Owner                Data size        Description
  GNU                  0x00000010       NT_GNU_ABI_TAG (ABI version tag)
```

This change is made to reduce the diff with readelf -n, so that it is
slightly easier to check what features readelf implements but we don't.

Reviewed By: grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D65847

llvm-svn: 368138

llvm/test/tools/llvm-readobj/gnu-notes.test
llvm/tools/llvm-readobj/ELFDumper.cpp

index 6cfc212..ba19630 100644 (file)
@@ -1,23 +1,23 @@
 ## Test tools are able to dump different types of notes.
 
 # RUN: yaml2obj --docnum=1 %s > %t1.so
-# RUN: llvm-readelf --notes %t1.so | FileCheck %s --check-prefix=GNU
+# RUN: llvm-readelf --notes %t1.so | FileCheck %s --check-prefix=GNU --strict-whitespace --match-full-lines
 # RUN: llvm-readobj --notes %t1.so | FileCheck %s --check-prefix=LLVM
 
-# GNU:      Displaying notes found at file offset 0x00000200 with length 0x00000020:
-# GNU-NEXT:   Owner                 Data size       Description
-# GNU-NEXT:   GNU                   0x00000010      NT_GNU_ABI_TAG (ABI version tag)
-# GNU-NEXT:     OS: Linux, ABI: 2.6.32
+#      GNU:Displaying notes found at file offset 0x00000200 with length 0x00000020:
+# GNU-NEXT:  Owner                Data size    Description
+# GNU-NEXT:  GNU                  0x00000010   NT_GNU_ABI_TAG (ABI version tag)
+# GNU-NEXT:    OS: Linux, ABI: 2.6.32
 
-# GNU:      Displaying notes found at file offset 0x00000220 with length 0x00000020:
-# GNU-NEXT:   Owner                 Data size       Description
-# GNU-NEXT:   GNU                  0x00000010       NT_GNU_BUILD_ID (unique build ID bitstring)
-# GNU-NEXT:     Build ID: 4fcb712aa6387724a9f465a32cd8c14b
+#      GNU:Displaying notes found at file offset 0x00000220 with length 0x00000020:
+# GNU-NEXT:  Owner                Data size    Description
+# GNU-NEXT:  GNU                  0x00000010   NT_GNU_BUILD_ID (unique build ID bitstring)
+# GNU-NEXT:    Build ID: 4fcb712aa6387724a9f465a32cd8c14b
 
-# GNU:      Displaying notes found at file offset 0x00000240 with length 0x0000001c:
-# GNU-NEXT:   Owner                 Data size       Description
-# GNU-NEXT:   GNU                  0x00000009       NT_GNU_GOLD_VERSION (gold version)
-# GNU-NEXT:     Version: gold 1.11
+#      GNU:Displaying notes found at file offset 0x00000240 with length 0x0000001c:
+# GNU-NEXT:  Owner                Data size    Description
+# GNU-NEXT:  GNU                  0x00000009   NT_GNU_GOLD_VERSION (gold version)
+# GNU-NEXT:    Version: gold 1.11
 
 # LLVM:      Notes [
 # LLVM-NEXT:   NoteSection {
index 0e81958..3a68245 100644 (file)
@@ -4315,7 +4315,7 @@ void GNUStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
                          const typename ELFT::Addr Size) {
     OS << "Displaying notes found at file offset " << format_hex(Offset, 10)
        << " with length " << format_hex(Size, 10) << ":\n"
-       << "  Owner                 Data size\tDescription\n";
+       << "  Owner                Data size \tDescription\n";
   };
 
   auto ProcessNote = [&](const Elf_Note &Note) {
@@ -4323,7 +4323,7 @@ void GNUStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
     ArrayRef<uint8_t> Descriptor = Note.getDesc();
     Elf_Word Type = Note.getType();
 
-    OS << "  " << Name << std::string(22 - Name.size(), ' ')
+    OS << "  " << left_justify(Name, 20) << ' '
        << format_hex(Descriptor.size(), 10) << '\t';
 
     if (Name == "GNU") {