[llvm-readobj/llvm-readelf] - Report a warning instead of a error when dumping a broken dynamic section.
It does not make sence to stop dumping the object if the broken
dynamic section was found. In this patch I changed the behavior from
"report an error" to "report a warning". This matches GNU.
Differential revision: https://reviews.llvm.org/D64472
llvm-svn: 365762
diff --git a/llvm/tools/llvm-readobj/ELFDumper.cpp b/llvm/tools/llvm-readobj/ELFDumper.cpp
index b70f69c..589199c 100644
--- a/llvm/tools/llvm-readobj/ELFDumper.cpp
+++ b/llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -134,8 +134,12 @@
const Type *Start = reinterpret_cast<const Type *>(Addr);
if (!Start)
return {Start, Start};
- if (EntSize != sizeof(Type) || Size % EntSize)
- reportError("Invalid entity size");
+ if (EntSize != sizeof(Type) || Size % EntSize) {
+ // TODO: Add a section index to this warning.
+ reportWarning("invalid section size (" + Twine(Size) +
+ ") or entity size (" + Twine(EntSize) + ")");
+ return {Start, Start};
+ }
return {Start, Start + (Size / EntSize)};
}
};