This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf] Print raw ELF note contents if we can't parse it
ClosedPublic

Authored by arichardson on Feb 10 2020, 3:55 PM.

Details

Summary

Currently, if the note name is known, but the value isn't we don't print
the contents.

Diff Detail

Event Timeline

arichardson created this revision.Feb 10 2020, 3:55 PM
MaskRay added a comment.EditedFeb 10 2020, 4:01 PM

Since this extends llvm-readelf output, can you also send an email to binutils@sourceware.org and check what output they want for GNU readelf? For llvm-readobj output, we are not bound to GNU decisions. Though, if the GNU output is not bad, aiming for consistency can usually make our implementation simpler.

arichardson retitled this revision from [UPSTREAM][llvm-readelf] Print raw ELF note contents if we can't parse it to [llvm-readelf] Print raw ELF note contents if we can't parse it.Feb 10 2020, 4:06 PM

Is there a test case that shows we don't print the raw data when the decoding is known?

arichardson marked an inline comment as done.Feb 11 2020, 2:41 AM

Is there a test case that shows we don't print the raw data when the decoding is known?

Not yet, but I've added a test case that would previously not print the contents for a GNU note of an unknown type.

llvm/tools/llvm-readobj/ELFDumper.cpp
4893

It seems like GNU readelf does not print the contents in this case.

Add a test showing the change in behaviour for GNU notes with unknown types

I assume that you've verified against GNU readelf all the behaviour that you're changing here?

llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test
2

It's unclear to me what this test is testing, so I can't really say whether this change is good. Would you mind adding a comment at the top of the test, either in this patch or a different one, briefly explaining its purpose, please? I imagine you might need to dig into the old commit messages for this file to find out.

llvm/tools/llvm-readobj/ELFDumper.cpp
4893

Nit: missing trailing full stop.

emaste added a comment.Feb 1 2021, 5:45 PM

Do you expect to pick this up again?

arichardson marked 2 inline comments as done.Feb 4 2021, 3:29 AM
jhenderson added inline comments.Feb 5 2021, 12:58 AM
llvm/test/tools/llvm-readobj/ELF/gnu-note-size.test
5–6

## for comments.

llvm/test/tools/llvm-readobj/ELF/note-amd.s
29

Maybe .note.unknown rather than invalid? Invalid to me suggests a recognised type, but broken data.

llvm/test/tools/llvm-readobj/ELF/note-amdgpu-invalid.s
90

Unless you're planning on fixing this immediately, it would be worth mentioning this test in the bug, or the TODO might get missed.

llvm/test/tools/llvm-readobj/ELF/note-amdgpu.test
106

As above: maybe .note.unknown for clarity?

llvm/test/tools/llvm-readobj/ELF/note-generic.s
4 ↗(On Diff #321370)

This looks wrong?

Also, I'm not sure why this test is changing as part of this change?

arichardson marked 5 inline comments as done.Feb 5 2021, 1:32 AM
arichardson added inline comments.
llvm/test/tools/llvm-readobj/ELF/note-generic.s
4 ↗(On Diff #321370)

Yes, sorry about that - it's a debugging leftover to compare against GNU readelf and the changes should be part of D96010. Will fix.

arichardson marked an inline comment as done.

Address review feedback

jhenderson accepted this revision.Feb 8 2021, 1:13 AM

Possibly this is a patch ordering thing, but some of the pre-merge bots are failing for this patch, I think. LGTM, apart than that.

This revision is now accepted and ready to land.Feb 8 2021, 1:13 AM
This revision was landed with ongoing or failed builds.Feb 9 2021, 8:59 AM
This revision was automatically updated to reflect the committed changes.

Possibly this is a patch ordering thing, but some of the pre-merge bots are failing for this patch, I think. LGTM, apart than that.

Yes, the problem was that I didn't mark D95953 as a parent of this change.