From 77be094e2f044bc43132a88c3ed3af36cc0ad6bb Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Tue, 17 May 2016 17:10:12 +0000 Subject: Change llvm-objdump, llvm-nm and llvm-size when reporting an object file error when the object is in an archive to use something like libx.a(foo.o) as part of the error message. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also changed llvm-objdump and llvm-size to be like llvm-nm and ignore non-object files in archives and not produce any error message. To do this Archive::Child::getAsBinary() was changed from ErrorOr<...> to Expected<...> then that was threaded up to its users. Converting this interface to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now the use of errorToErrorCode() is still used in one place yet to be fully converted. Again there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comments for those. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@269784 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/Object/macho-invalid.test | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/Object/macho-invalid.test') diff --git a/test/Object/macho-invalid.test b/test/Object/macho-invalid.test index 35fc5c6d1cb..55d9d25ab72 100644 --- a/test/Object/macho-invalid.test +++ b/test/Object/macho-invalid.test @@ -56,6 +56,10 @@ RUN: llvm-nm -pax %p/Inputs/macho-invalid-symbol-name-past-eof 2>&1 \ RUN: | FileCheck -check-prefix NAME-PAST-EOF-nm-pax %s NAME-PAST-EOF-nm-pax: 0000000000000000 64 00 0000 fe000002 bad string index +RUN: not llvm-objdump -t %p/Inputs/macho-bad-archive1.a 2>&1 \ +RUN: | FileCheck -check-prefix NAME-PAST-EOF-ARCHIVE %s +NAME-PAST-EOF-ARCHIVE: macho-bad-archive1.a(macho-invalid-symbol-name-past-eof) truncated or malformed object (bad string index: 4261412866 for symbol at index 0) + RUN: llvm-nm %p/Inputs/macho-invalid-section-index-getSectionRawName 2>&1 \ RUN: | FileCheck -check-prefix INVALID-SECTION-IDX-SYMBOL-SEC %s INVALID-SECTION-IDX-SYMBOL-SEC: 0000000100000000 S __mh_execute_header @@ -74,3 +78,6 @@ INVALID-HEADER: The file was not recognized as a valid object file RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho64-invalid-incomplete-segment-load-command 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC %s INCOMPLETE-SEGMENT-LOADC: truncated or malformed object (load commands extend past the end of the file) + +RUN: not llvm-objdump -macho -private-headers %p/Inputs/macho-bad-archive2.a 2>&1 | FileCheck -check-prefix INCOMPLETE-SEGMENT-LOADC-ARCHIVE %s +INCOMPLETE-SEGMENT-LOADC-ARCHIVE: macho-bad-archive2.a(macho64-invalid-incomplete-segment-load-command) truncated or malformed object (load commands extend past the end of the file) -- cgit v1.2.3