This is an archive of the discontinued LLVM Phabricator instance.

[llvm/Object] - Make ELFObjectFile::getRelocatedSection return Expected<section_iterator>.
ClosedPublic

Authored by grimar on Oct 18 2019, 6:59 AM.

Details

Summary

It returns just a section_iterator currently and have a report_fatal_error call inside.
This change adds a way to return errors and handle them on caller sides.

The patch also changes/improves current users and adds test cases.

Tools/places affected: llvm-readobj, llvm-objdump, llvm-cxxdump, llvm-dwarfdump, RuntimeDyld

Diff Detail

Event Timeline

grimar created this revision.Oct 18 2019, 6:59 AM

Generally makes sense. Hopefully some other folks chime in too, though.

(I wonder if it makes sense not to necessarily test this codepath in every tool - seems like maybe too much test coverage)

rupprecht accepted this revision.Oct 18 2019, 2:38 PM
This revision is now accepted and ready to land.Oct 18 2019, 2:38 PM

Generally makes sense. Hopefully some other folks chime in too, though.

(I wonder if it makes sense not to necessarily test this codepath in every tool - seems like maybe too much test coverage)

Yes. I thought about the same.

I think it is good to have in llvm-readobj, llvm-objdump and llvm-dwarfdump, because these are tools used for inspecting corrupt
objects more often and it worth to check their error message text reported and the behavior. Adding tests for them was my primary
intention.

I added a test for llvm-cxxdump because it was easy, but I never used this tool before or wrote patches for it. I do not know how
much it is excessive.

I didn't add a test for RuntimeDyld because I am not familiar with it too and did not find how to do it quickly. Also I did not see any
other error checking tests around, so I supposed it might be not so important (to check a one more possible broken input case).

Given all the above I am going to commit this tomorrow. but will be happy to address any post-review comments/requests if any.

MaskRay accepted this revision.Oct 20 2019, 8:41 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2019, 4:08 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
jhenderson added inline comments.Oct 28 2019, 9:54 AM
llvm/test/tools/llvm-readobj/stack-sizes.test
646

Nit: "Here the sh_info..."