Index: llvm/test/tools/llvm-readobj/archive.test =================================================================== --- llvm/test/tools/llvm-readobj/archive.test +++ llvm/test/tools/llvm-readobj/archive.test @@ -1,3 +1,5 @@ +## Test how we dump archives. + ## Show that dumping operations apply to all members in an archive. # RUN: rm -f %t.a @@ -82,3 +84,17 @@ Characteristics: [ ] sections: [] symbols: [] + +## Here we test that we report a warning and continue dumping when an archive contains +## a unrecognized object. We place a dummy archive to another archive in the middle, +## so that it is placed between two valid objects. + +# RUN: rm -f %t2.a +# RUN: llvm-ar rc %t.dir/broken.a %t.dir/trivial.obj.elf-x86-64 +# RUN: llvm-ar qc %t2.a %t.dir/trivial.obj.elf-x86-64 %t.dir/broken.a %t.dir/trivial.obj.elf-x86-64 +# RUN: llvm-readobj --all %t2.a 2>&1 | FileCheck %s -DARFILE="%t2.a" --check-prefix=BROKEN +# RUN: llvm-readelf --all %t2.a 2>&1 | FileCheck %s -DARFILE="%t2.a" --check-prefix=BROKEN + +# BROKEN: File: [[ARFILE]](trivial.obj.elf-x86-64) +# BROKEN: warning: '[[ARFILE]]': Unrecognized file type. +# BROKEN: File: [[ARFILE]](trivial.obj.elf-x86-64) Index: llvm/tools/llvm-readobj/llvm-readobj.cpp =================================================================== --- llvm/tools/llvm-readobj/llvm-readobj.cpp +++ llvm/tools/llvm-readobj/llvm-readobj.cpp @@ -584,8 +584,8 @@ else if (COFFImportFile *Imp = dyn_cast(&*ChildOrErr.get())) dumpCOFFImportFile(Imp, Writer); else - reportError(errorCodeToError(readobj_error::unrecognized_file_format), - Arc->getFileName()); + reportWarning(errorCodeToError(readobj_error::unrecognized_file_format), + Arc->getFileName()); } if (Err) reportError(std::move(Err), Arc->getFileName());