diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp --- a/bolt/lib/Rewrite/RewriteInstance.cpp +++ b/bolt/lib/Rewrite/RewriteInstance.cpp @@ -5135,8 +5135,10 @@ "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) {