[PATCH] D86771: [llvm-readobj/elf] - Don't fail when dumping an archive with an object that can't be recognized.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 28 03:35:03 PDT 2020
grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added a subscriber: rupprecht.
Herald added a project: LLVM.
grimar requested review of this revision.
Imagine we have an archive that has 3 objects in the following order:
<valid known object>,<unknown object> and <valid known object>.
Currently llvm-readelf/obj report an error and stops dumping in the middle.
This patch changes the error reported to warning.
I am improving this warning in a follow-up that will be posted soon.
https://reviews.llvm.org/D86771
Files:
llvm/test/tools/llvm-readobj/archive.test
llvm/tools/llvm-readobj/llvm-readobj.cpp
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<COFFImportFile>(&*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());
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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86771.288576.patch
Type: text/x-patch
Size: 1852 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200828/ba3f32cf/attachment.bin>
More information about the llvm-commits
mailing list