[BOLT][NFC] Check errors from Obj.dynamicEntries

Addresses fuzzer crash

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D121336
This commit is contained in:
Amir Ayupov 2022-03-09 20:24:20 -08:00
parent 83b8878fbb
commit d16bbc5340
1 changed files with 4 additions and 2 deletions

View File

@ -5135,8 +5135,10 @@ Error RewriteInstance::readELFDynamic(ELFObjectFile<ELFT> *File) {
"dynamic section sizes should match");
// Go through all dynamic entries to locate entries of interest.
typename ELFT::DynRange DynamicEntries =
cantFail(Obj.dynamicEntries(), "error accessing dynamic table");
auto DynamicEntriesOrErr = Obj.dynamicEntries();
if (!DynamicEntriesOrErr)
return DynamicEntriesOrErr.takeError();
typename ELFT::DynRange DynamicEntries = DynamicEntriesOrErr.get();
for (const Elf_Dyn &Dyn : DynamicEntries) {
switch (Dyn.d_tag) {