From: Fangrui Song Date: Wed, 7 Aug 2019 09:13:11 +0000 (+0000) Subject: [llvm-readelf] --notes: move 'Data size' column left by 1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ce10b63096b36ab886198470afbf88a73daf7a19;p=llvm [llvm-readelf] --notes: move 'Data size' column left by 1 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@368138 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/tools/llvm-readobj/gnu-notes.test b/test/tools/llvm-readobj/gnu-notes.test index 6cfc2125682..ba19630eaf4 100644 --- a/test/tools/llvm-readobj/gnu-notes.test +++ b/test/tools/llvm-readobj/gnu-notes.test @@ -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 { diff --git a/tools/llvm-readobj/ELFDumper.cpp b/tools/llvm-readobj/ELFDumper.cpp index 0e819586f97..3a68245d264 100644 --- a/tools/llvm-readobj/ELFDumper.cpp +++ b/tools/llvm-readobj/ELFDumper.cpp @@ -4315,7 +4315,7 @@ void GNUStyle::printNotes(const ELFFile *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::printNotes(const ELFFile *Obj) { ArrayRef 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") {