This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Change how we create DynRegionInfo objects. NFCI.
ClosedPublic

Authored by grimar on Aug 20 2020, 8:44 AM.

Details

Summary

Currently we have checkDRI and two createDRIFrom methods which
are used to create DynRegionInfo objects.

And we have an issue: constructions like:
ObjF->getELFFile()->base() + P->p_offset
that are used in createDRIFrom functions might overflow.

I had to revert D85519 which triggered such UBSan failure.

To resolve it, I am suggesting this NFC, which simplifies and
generalizes how we create DynRegionInfo objects.

It will allow us to introduce more/better validation checks in a single place.
It also will allow to change createDRI to return Expected<> so
that we will be able to stop using the reportError, which
is used inside currently, and have a warning instead.

Diff Detail

Event Timeline

grimar created this revision.Aug 20 2020, 8:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 20 2020, 8:44 AM
Herald added a subscriber: rupprecht. · View Herald Transcript
grimar requested review of this revision.Aug 20 2020, 8:44 AM

This is a phab issue, btw: "grimar added a reverted change: D85519: [llvm-readobj/elf] - Refine the code for broken PT_DYNAMIC segment diagnostic.."
I've just edited the diff description. Seems using the "revert" word and diff ID in a same sentence was not the best idea..

MaskRay accepted this revision.Aug 20 2020, 2:37 PM
This revision is now accepted and ready to land.Aug 20 2020, 2:37 PM
jhenderson accepted this revision.Aug 21 2020, 12:08 AM

Seems reasonable to me.