This is an archive of the discontinued LLVM Phabricator instance.

[lib/Object] - Make ELFObjectFile::getSymbol() return Expected<>.
ClosedPublic

Authored by grimar on Dec 15 2020, 6:44 AM.

Details

Summary

This was requested in comments for D93209:
https://reviews.llvm.org/D93209#inline-871192

D93209 fixes an issue with ELFFile<ELFT>::getEntry,
after what getSymbol starts calling report_fatal_error for previously
missed invalid cases.

This patch makes it return Expected<> and updates callers.
For few of them I had to add new report_fatal_error calls. But I see no
way to avoid it currently. The change would affects too many places, e.g:
getSymbolBinding and other methods are used from ELFSymbolRef
which is used too many places across LLVM.

Diff Detail

Event Timeline

grimar created this revision.Dec 15 2020, 6:44 AM
grimar requested review of this revision.Dec 15 2020, 6:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 15 2020, 6:44 AM

LG

llvm/include/llvm/Object/ELFObjectFile.h
414

Just return EF.template getEntry<Elf_Sym>(Sym.d.a, Sym.d.b);

grimar marked an inline comment as done.Dec 15 2020, 11:49 PM
grimar added inline comments.
llvm/include/llvm/Object/ELFObjectFile.h
414

Right, thanks!

jhenderson accepted this revision.Dec 16 2020, 12:56 AM

LGTM, with @MaskRay's suggestion. We can work on bubbling up the Error/Expected in due course to get rid of the report_fatal_error calls.

This revision is now accepted and ready to land.Dec 16 2020, 12:56 AM
This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.