llvm/test/Object/nm-archive.test
Kevin Enderby 77be094e2f 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
2016-05-17 17:10:12 +00:00

71 lines
2.5 KiB
Plaintext

RUN: llvm-nm -a %p/Inputs/archive-test.a-coff-i386 \
RUN: | FileCheck %s -check-prefix COFF
COFF: trivial-object-test.coff-i386:
COFF-NEXT: 00000000 d .data
COFF-NEXT: 00000000 t .text
COFF-NEXT: 00000000 d L_.str
COFF-NEXT: U _SomeOtherFunction
COFF-NEXT: 00000000 T _main
COFF-NEXT: U _puts
RUN: llvm-nm -a -o %p/Inputs/archive-test.a-coff-i386 \
RUN: | FileCheck %s -check-prefix COFF-o
COFF-o: {{.*}}/archive-test.a-coff-i386:trivial-object-test.coff-i386: 00000000 d .data
COFF-o: {{.*}}/archive-test.a-coff-i386:trivial-object-test.coff-i386: 00000000 t .text
COFF-o: {{.*}}/archive-test.a-coff-i386:trivial-object-test.coff-i386: 00000000 d L_.str
COFF-o: {{.*}}/archive-test.a-coff-i386:trivial-object-test.coff-i386: U _SomeOtherFunction
COFF-o: {{.*}}/archive-test.a-coff-i386:trivial-object-test.coff-i386: 00000000 T _main
COFF-o: {{.*}}/archive-test.a-coff-i386:trivial-object-test.coff-i386: U _puts
RUN: llvm-as %p/Inputs/trivial.ll -o=%t1
RUN: rm -f %t2
RUN: llvm-ar rcs %t2 %t1
RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE
RUN: rm -f %t2
RUN: llvm-lib /out:%t2 %t1
RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE
RUN: rm -f %t2
RUN: echo /out:%t2 %t1 > %t.rsp
RUN: llvm-lib @%t.rsp
RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE
BITCODE: U SomeOtherFunction
BITCODE-NEXT: T main
BITCODE-NEXT: U puts
BITCODE-NEXT: D var
Test we don't error with an archive with no symtab.
RUN: llvm-nm %p/Inputs/archive-test.a-gnu-no-symtab
Or in an archive with no symtab or string table.
RUN: llvm-nm %p/Inputs/archive-test.a-gnu-minimal
And don't crash when asked to print a non-existing symtab.
RUN: llvm-nm -M %p/Inputs/archive-test.a-gnu-minimal
Don't reject an empty archive.
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 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
THIN: IsNAN.o:
THIN: 00000014 T _ZN4llvm5IsNANEd
THIN: 00000000 T _ZN4llvm5IsNANEf
THIN: U __isnan
THIN: U __isnanf