This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf] - Introduce describe() helper functions.
ClosedPublic

Authored by grimar on Jul 21 2020, 7:26 AM.

Details

Summary

These functions can be used to generate strings like
"SHT_?? section with index ?" to describe sections in error/warning messages,
what helps to simplify and generalize them.

Also this allows to isolate the following common code pattern:
&Sec - &cantFail(Obj->sections()).front();

Diff Detail

Event Timeline

grimar created this revision.Jul 21 2020, 7:26 AM
Herald added a project: Restricted Project. · View Herald Transcript
MaskRay accepted this revision.Jul 21 2020, 10:01 AM

Thanks!

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

The previous "RELPLT" seems more specific than SHT_PROGBITS. Do we need to change it?

This revision is now accepted and ready to land.Jul 21 2020, 10:01 AM
jhenderson accepted this revision.Jul 22 2020, 1:04 AM

Just a nit from me. Otherwise LGTM.

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

Nit: accidental ';'

grimar marked 3 inline comments as done.Jul 22 2020, 4:27 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
3127

So now in mips-plt.test
instead of unable to get a symbol table linked to the RELPLT section with index 2
we report unable to get a symbol table linked to the SHT_PROGBITS section with index 2

I think this change is neutral, becase it probably was not clear what is RELPLT anyways (the message could mention a section that was found at the address specified in DT_JMPREL instead and perhaps, the better name is JMPREL then.
Also, in the case of a broken object/invalid dynamic tag value, we could have something else instead of SHT_PROGBITS, so printing a section type looks useful too.

Perhaps a better mesage can be:

unable to get a symbol table linked to the SHT_PROGBITS section with index 2, found at address 0x12345 (DT_JMPREL)
This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.