[PATCH] D13989: This removes the eating of the error in Archive::Child::getSize() when the charactersin the size field in the archive header for the member is not a number.

Kevin Enderby via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 22 11:51:13 PDT 2015


enderby created this revision.
enderby added reviewers: rafael, ruiu.
enderby added subscribers: llvm-commits, lhames.

To do this we have all of the needed methods return ErrorOr to push them up until we get out of lib.
Then the tools and can handle the error in whatever way is appropriate for that tool.

So the solution is to plumb all the ErrorOr stuff through everything that touches archives.
This include its iterators as one can create an Archive object but the first or any other
Child object may fail to be created due to a bad size field in its header.

Thanks to Lang Hames on the changes making child_iterator contain an
ErrorOr<Child> instead of a Child and the needed changes to ErrorOr.h to add
operator overloading for * and -> .

We don’t want to use llvm_unreachable() as it calls abort() and is produces a “crash”
and using report_fatal_error() to move the error checking will cause the program to
stop, neither of which are really correct in library code. There are still some uses of
these that should be cleaned up in this library code for other than the size field.

Also corrected the code where the size gets us to the “at the end of the archive”
which is OK but past the end of the archive will return object_error::parse_failed now.

The test cases use archives with text files so one can see the non-digit character,
in this case a ‘%’, in the size field.

These changes will require corresponding changes to the lld project.  That patch will be posted next.
And that will be committed immediately after this change when committed.  But this revision will cause lld failures with this alone which is expected.

http://reviews.llvm.org/D13989

Files:
  include/llvm/Object/Archive.h
  include/llvm/Support/ErrorOr.h
  lib/ExecutionEngine/MCJIT/MCJIT.cpp
  lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
  lib/Object/Archive.cpp
  lib/Object/ArchiveWriter.cpp
  test/tools/llvm-objdump/Inputs/malformed-archives/libbogus1.a
  test/tools/llvm-objdump/Inputs/malformed-archives/libbogus2.a
  test/tools/llvm-objdump/Inputs/malformed-archives/libbogus3.a
  test/tools/llvm-objdump/malformed-archives.test
  tools/dsymutil/BinaryHolder.cpp
  tools/llvm-ar/llvm-ar.cpp
  tools/llvm-cxxdump/llvm-cxxdump.cpp
  tools/llvm-nm/llvm-nm.cpp
  tools/llvm-objdump/MachODump.cpp
  tools/llvm-objdump/llvm-objdump.cpp
  tools/llvm-readobj/llvm-readobj.cpp
  tools/llvm-size/llvm-size.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13989.38151.patch
Type: text/x-patch
Size: 35187 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151022/e5bc47ee/attachment.bin>


More information about the llvm-commits mailing list