Index: include/llvm/Object/ELFTypes.h =================================================================== --- include/llvm/Object/ELFTypes.h +++ include/llvm/Object/ELFTypes.h @@ -631,6 +631,7 @@ // Stop iteration and indicate an overflow. void stopWithOverflowError() { Nhdr = nullptr; + ErrorAsOutParameter EAOP(Err); *Err = make_error("ELF note overflows container", object_error::parse_failed); } Index: tools/llvm-objcopy/ELF/ELFObjcopy.cpp =================================================================== --- tools/llvm-objcopy/ELF/ELFObjcopy.cpp +++ tools/llvm-objcopy/ELF/ELFObjcopy.cpp @@ -123,16 +123,16 @@ if (Phdr.p_type != PT_NOTE) continue; Error Err = Error::success(); - if (Err) - llvm_unreachable("Error::success() was an error."); + ArrayRef Result; for (const auto &Note : In.notes(Phdr, Err)) { - if (Err) - return std::move(Err); - if (Note.getType() == NT_GNU_BUILD_ID && Note.getName() == ELF_NOTE_GNU) - return Note.getDesc(); + if (Note.getType() == NT_GNU_BUILD_ID && Note.getName() == ELF_NOTE_GNU) { + Result = Note.getDesc(); + break; + } } if (Err) return std::move(Err); + return Result; } return createStringError(llvm::errc::invalid_argument, "Could not find build ID.");