Page MenuHomePhabricator

[llvm-readobj] Include section name of notes.

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



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

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


Displaying notes found in:

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).


Diff Detail

Event Timeline

rupprecht created this revision.Mar 4 2020, 2:22 PM
Herald added a reviewer: alexshap. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
MaskRay added inline comments.Mar 4 2020, 3:04 PM

Worth a comment that it has no name.


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



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

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.