diff options
author | Kevin Enderby <enderby@apple.com> | 2016-05-17 17:10:12 +0000 |
---|---|---|
committer | Kevin Enderby <enderby@apple.com> | 2016-05-17 17:10:12 +0000 |
commit | 77be094e2f044bc43132a88c3ed3af36cc0ad6bb (patch) | |
tree | 57824f52bf558ddf53ce660bf1101f82d6c65610 /test/Object | |
parent | d307f96d685d22518d56f60c654786371fd3104f (diff) |
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.
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
Diffstat (limited to 'test/Object')
-rw-r--r-- | test/Object/Inputs/macho-bad-archive1.a | bin | 0 -> 5544 bytes | |||
-rw-r--r-- | test/Object/Inputs/macho-bad-archive2.a | bin | 0 -> 1084 bytes | |||
-rw-r--r-- | test/Object/macho-invalid.test | 7 | ||||
-rw-r--r-- | test/Object/nm-archive.test | 7 |
4 files changed, 11 insertions, 3 deletions
diff --git a/test/Object/Inputs/macho-bad-archive1.a b/test/Object/Inputs/macho-bad-archive1.a Binary files differnew file mode 100644 index 00000000000..42ef43f5932 --- /dev/null +++ b/test/Object/Inputs/macho-bad-archive1.a diff --git a/test/Object/Inputs/macho-bad-archive2.a b/test/Object/Inputs/macho-bad-archive2.a Binary files differnew file mode 100644 index 00000000000..006822f0001 --- /dev/null +++ b/test/Object/Inputs/macho-bad-archive2.a 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) diff --git a/test/Object/nm-archive.test b/test/Object/nm-archive.test index 8f8cdbe9f08..1a13c23f245 100644 --- a/test/Object/nm-archive.test +++ b/test/Object/nm-archive.test @@ -55,9 +55,10 @@ RUN: llvm-nm %p/Inputs/archive-test.a-empty This archive has an unaligned member and a unknown format member. GNU AR is able to parse the unaligned member and warns about the member with -the unknown format. We should probably simply warn on both. For now just check -that we don't produce an error. -RUN: llvm-nm %p/Inputs/corrupt-archive.a +the unknown format. We should probably simply warn on both. For now we just +produce an error for the unknown format. +RUN: not llvm-nm %p/Inputs/corrupt-archive.a 2>&1 | FileCheck %s -check-prefix CORRUPT +CORRUPT: corrupt-archive.a(trivial-object-test2.elf-x86-64) Invalid data was encountered while parsing the file RUN: llvm-nm %p/Inputs/thin.a | FileCheck %s -check-prefix THIN |