This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Include section name of notes.
ClosedPublic

Authored by rupprecht on Mar 4 2020, 2:22 PM.

Details

Summary

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.

Diff Detail

Event Timeline

rupprecht created this revision.Mar 4 2020, 2:22 PM
MaskRay added inline comments.Mar 4 2020, 3:04 PM
llvm/test/tools/llvm-readobj/ELF/gnu-notes.test
64

Worth a comment that it has no name.

75

This will be the remaining test for the Displaying notes found at file offset ... form.

Worth a comment that it has no name.

rupprecht updated this revision to Diff 248368.Mar 4 2020, 6:46 PM
rupprecht marked 2 inline comments as done.
  • Update test comments
rupprecht updated this revision to Diff 248370.Mar 4 2020, 6:47 PM

Upload correct patch

MaskRay accepted this revision.Mar 4 2020, 7:42 PM
This revision is now accepted and ready to land.Mar 4 2020, 7:42 PM
grimar added inline comments.Mar 5 2020, 12:27 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
5134

Probably,

/*SecName=*/None
6278

Should we always print fields? (i.e. print Name=something for !SecName).
Is it the only case for LLVM output where we can omit/print field I guess?
(I remember we had something like this before somewhere and removed it).

rupprecht updated this revision to Diff 248504.Mar 5 2020, 9:00 AM
rupprecht marked 3 inline comments as done.
  • Annotate SecName param
  • Use <?> for unknown section names
rupprecht added inline comments.Mar 5 2020, 9:04 AM
llvm/tools/llvm-readobj/ELFDumper.cpp
6278

Yes, we do have a custom of printing <?> for unknown sections/symbols. Updated here, but not for GNU output format, for better compatibility.

This revision was automatically updated to reflect the committed changes.