[llvm-readobj] Include section name of notes.
authorJordan Rupprecht <rupprecht@google.com>
Wed, 4 Mar 2020 22:20:48 +0000 (14:20 -0800)
committerJordan Rupprecht <rupprecht@google.com>
Thu, 5 Mar 2020 17:53:14 +0000 (09:53 -0800)
commitc140810ea158074c97bff4d3bd66c0e06aed6d93
treeb5abcea847aeea497f5945ec0099b50e1e98c7f1
parentc93f1046fc15ca01f55c2e7955e88eaf8e0569d6
[llvm-readobj] Include section name of notes.

This changes the output of `llvm-readelf -n` from:

```
Displaying notes found at file offset 0x<...> with length 0x<...>:
```

to:

```
Displaying notes found in: .note.foo
```

And similarly, adds a `Name:` field to the `llvm-readobj -n` output for notes.

This change not only increases GNU compatibility, it also makes it much easier to read notes. Note that we still fall back to printing the file offset/length in cases where we don't have a section name, such as when printing notes in program headers or printing notes in a partially stripped file (GNU readelf does the same).

Fixes llvm.org/PR41339.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D75647
17 files changed:
lld/test/ELF/partition-notes.s
llvm/test/CodeGen/AMDGPU/code-object-v3.ll
llvm/test/tools/llvm-objcopy/ELF/add-note.test
llvm/test/tools/llvm-readobj/ELF/AArch64/aarch64-note-gnu-property.s
llvm/test/tools/llvm-readobj/ELF/all.test
llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test
llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
llvm/test/tools/llvm-readobj/ELF/note-amd.s
llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test
llvm/test/tools/llvm-readobj/ELF/note-core-ntfile.test
llvm/test/tools/llvm-readobj/ELF/note-core.test
llvm/test/tools/llvm-readobj/ELF/note-freebsd.s
llvm/test/tools/llvm-readobj/ELF/note-generic.s
llvm/test/tools/llvm-readobj/ELF/note-gnu-property.s
llvm/test/tools/llvm-readobj/ELF/note-gnu-property2.s
llvm/test/tools/llvm-readobj/ELF/note-unknown.s
llvm/tools/llvm-readobj/ELFDumper.cpp