diff options
author | Stephen Hines <srhines@google.com> | 2013-08-07 15:07:10 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2013-08-07 15:07:10 -0700 |
commit | fab2daa4a1127ecb217abe2b07c1769122b6fee1 (patch) | |
tree | 268ebfd1963fd98ba412e76819afdf95a7d4267b /test/Object | |
parent | 8197ac1c1a0a91baa70c4dea8cb488f254ef974c (diff) | |
parent | 10251753b6897adcd22cc981c0cc42f348c109de (diff) | |
download | external_llvm-fab2daa4a1127ecb217abe2b07c1769122b6fee1.zip external_llvm-fab2daa4a1127ecb217abe2b07c1769122b6fee1.tar.gz external_llvm-fab2daa4a1127ecb217abe2b07c1769122b6fee1.tar.bz2 |
Merge commit '10251753b6897adcd22cc981c0cc42f348c109de' into merge-20130807
Conflicts:
lib/Archive/ArchiveReader.cpp
lib/Support/Unix/PathV2.inc
Change-Id: I29d8c1e321a4a380b6013f00bac6a8e4b593cc4e
Diffstat (limited to 'test/Object')
36 files changed, 531 insertions, 5 deletions
diff --git a/test/Object/Inputs/GNU.a b/test/Object/Inputs/GNU.a Binary files differnew file mode 100644 index 0000000..4c09881 --- /dev/null +++ b/test/Object/Inputs/GNU.a diff --git a/test/Object/Inputs/IsNAN.o b/test/Object/Inputs/IsNAN.o Binary files differnew file mode 100644 index 0000000..7b3a12a --- /dev/null +++ b/test/Object/Inputs/IsNAN.o diff --git a/test/Object/Inputs/MacOSX.a b/test/Object/Inputs/MacOSX.a Binary files differnew file mode 100644 index 0000000..8ba1e6d --- /dev/null +++ b/test/Object/Inputs/MacOSX.a diff --git a/test/Object/Inputs/SVR4.a b/test/Object/Inputs/SVR4.a Binary files differnew file mode 100644 index 0000000..3947813 --- /dev/null +++ b/test/Object/Inputs/SVR4.a diff --git a/test/Object/Inputs/archive-test.a-corrupt-symbol-table b/test/Object/Inputs/archive-test.a-corrupt-symbol-table Binary files differnew file mode 100644 index 0000000..34e5ed7 --- /dev/null +++ b/test/Object/Inputs/archive-test.a-corrupt-symbol-table diff --git a/test/Object/Inputs/archive-test.a-empty b/test/Object/Inputs/archive-test.a-empty new file mode 100644 index 0000000..8b277f0 --- /dev/null +++ b/test/Object/Inputs/archive-test.a-empty @@ -0,0 +1 @@ +!<arch> diff --git a/test/Object/Inputs/archive-test.a-gnu-minimal b/test/Object/Inputs/archive-test.a-gnu-minimal new file mode 100644 index 0000000..a243273 --- /dev/null +++ b/test/Object/Inputs/archive-test.a-gnu-minimal @@ -0,0 +1,2 @@ +!<arch> +test/ 1372964340 1000 1000 100664 0 ` diff --git a/test/Object/Inputs/archive-test.a-gnu-no-symtab b/test/Object/Inputs/archive-test.a-gnu-no-symtab new file mode 100644 index 0000000..0a5b237 --- /dev/null +++ b/test/Object/Inputs/archive-test.a-gnu-no-symtab @@ -0,0 +1,5 @@ +!<arch> +// 24 ` +a-very-long-file-name/ + +/0 1372864788 1000 1000 100664 0 ` diff --git a/test/Object/Inputs/evenlen b/test/Object/Inputs/evenlen new file mode 100644 index 0000000..59ee8d5 --- /dev/null +++ b/test/Object/Inputs/evenlen @@ -0,0 +1 @@ +evenlen diff --git a/test/Object/Inputs/macho-universal.x86_64.i386 b/test/Object/Inputs/macho-universal.x86_64.i386 Binary files differnew file mode 100755 index 0000000..36d5fc2 --- /dev/null +++ b/test/Object/Inputs/macho-universal.x86_64.i386 diff --git a/test/Object/Inputs/oddlen b/test/Object/Inputs/oddlen new file mode 100644 index 0000000..8cf5bd1 --- /dev/null +++ b/test/Object/Inputs/oddlen @@ -0,0 +1 @@ +oddlen diff --git a/test/Object/Inputs/trivial-object-test2.elf-x86-64 b/test/Object/Inputs/trivial-object-test2.elf-x86-64 Binary files differnew file mode 100644 index 0000000..9124518 --- /dev/null +++ b/test/Object/Inputs/trivial-object-test2.elf-x86-64 diff --git a/test/Object/Inputs/very_long_bytecode_file_name.bc b/test/Object/Inputs/very_long_bytecode_file_name.bc Binary files differnew file mode 100644 index 0000000..f7fce24 --- /dev/null +++ b/test/Object/Inputs/very_long_bytecode_file_name.bc diff --git a/test/Object/Inputs/xpg4.a b/test/Object/Inputs/xpg4.a Binary files differnew file mode 100644 index 0000000..b2bdb51 --- /dev/null +++ b/test/Object/Inputs/xpg4.a diff --git a/test/Object/ar-create.test b/test/Object/ar-create.test new file mode 100644 index 0000000..95d994e --- /dev/null +++ b/test/Object/ar-create.test @@ -0,0 +1,17 @@ +Test which operations create an archive and which don't. + +RUN: touch %t +RUN: rm -f %t.foo.a +RUN: not llvm-ar p %t.foo.a %t 2>&1 | FileCheck %s +RUN: not llvm-ar d %t.foo.a %t 2>&1 | FileCheck %s +RUN: not llvm-ar m %t.foo.a %t 2>&1 | FileCheck %s +RUN: not llvm-ar t %t.foo.a %t 2>&1 | FileCheck %s +RUN: not llvm-ar x %t.foo.a %t 2>&1 | FileCheck %s + +RUN: llvm-ar q %t.foo.a %t 2>&1 | FileCheck --check-prefix=CREATE %s +RUN: rm -f %t.foo.a +RUN: llvm-ar r %t.foo.a %t 2>&1 | FileCheck --check-prefix=CREATE %s +RUN: rm -f %t.foo.a + +CHECK: llvm-ar{{(.exe|.EXE)?}}: error loading '{{[^']+}}.foo.a': +CREATE: creating {{.*}}.foo.a diff --git a/test/Object/archive-delete.test b/test/Object/archive-delete.test new file mode 100644 index 0000000..552b0e7 --- /dev/null +++ b/test/Object/archive-delete.test @@ -0,0 +1,30 @@ +Test the 'd' operation in llvm-ar + +REQUIRES: shell + +RUN: cd %T + +RUN: rm -f %t.a +RUN: cp %p/Inputs/GNU.a %t.a +RUN: llvm-ar d %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + +RUN: rm -f %t.a +RUN: cp %p/Inputs/MacOSX.a %t.a +RUN: llvm-ar d %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + +RUN: rm -f %t.a +RUN: cp %p/Inputs/SVR4.a %t.a +RUN: llvm-ar d %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + +RUN: rm -f %t.a +RUN: cp %p/Inputs/xpg4.a %t.a +RUN: llvm-ar d %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + + +CHECK: evenlen +CHECK-NEXT: oddlen +CHECK-NEXT: IsNAN.o diff --git a/test/Object/archive-error-tmp.txt b/test/Object/archive-error-tmp.txt new file mode 100644 index 0000000..0618986 --- /dev/null +++ b/test/Object/archive-error-tmp.txt @@ -0,0 +1,9 @@ +REQUIRES: shell + +Test that no temporary file is left behind on error. + +RUN: rm -rf %t +RUN: mkdir %t +RUN: not llvm-ar rc %t/foo.a . +RUN: rmdir %t + diff --git a/test/Object/archive-extract-dir.test b/test/Object/archive-extract-dir.test new file mode 100644 index 0000000..c718f90 --- /dev/null +++ b/test/Object/archive-extract-dir.test @@ -0,0 +1,13 @@ +REQUIRES: shell + +RUN: mkdir -p %t +RUN: cd %t +RUN: rm -rf foo +RUN: echo foo > foo +RUN: rm -f test.a +RUN: llvm-ar rc test.a foo +RUN: rm foo +RUN: mkdir foo +RUN: not llvm-ar x test.a foo 2>&1 | FileCheck %s + +CHECK: foo: Is a directory diff --git a/test/Object/archive-format.test b/test/Object/archive-format.test new file mode 100644 index 0000000..20ac1a0 --- /dev/null +++ b/test/Object/archive-format.test @@ -0,0 +1,22 @@ +Test the exact archive format. In particular, test which file names use the +string table or not. + +REQUIRES: shell + +RUN: mkdir -p %t +RUN: cd %t + +RUN: echo bar > 0123456789abcde +RUN: echo zed > 0123456789abcdef + +RUN: rm -f test.a +RUN: llvm-ar rc test.a 0123456789abcde 0123456789abcdef +RUN: cat test.a | FileCheck -strict-whitespace %s + +CHECK: !<arch> +CHECK-NEXT: // 18 ` +CHECK-NEXT: 0123456789abcdef/ +CHECK-NEXT: 0123456789abcde/{{................................}}4 ` +CHECK-NEXT: bar +CHECK-NEXT: /0 {{................................}}4 ` +CHECK-NEXT: zed diff --git a/test/Object/archive-move.test b/test/Object/archive-move.test new file mode 100644 index 0000000..0378e91 --- /dev/null +++ b/test/Object/archive-move.test @@ -0,0 +1,50 @@ +Test the 'm' operation in llvm-ar + +REQUIRES: shell + +RUN: cd %T + +RUN: rm -f %t.a +RUN: cp %p/Inputs/GNU.a %t.a +RUN: llvm-ar m %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + +RUN: rm -f %t.a +RUN: cp %p/Inputs/MacOSX.a %t.a +RUN: llvm-ar m %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + +RUN: rm -f %t.a +RUN: cp %p/Inputs/SVR4.a %t.a +RUN: llvm-ar m %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + +RUN: rm -f %t.a +RUN: cp %p/Inputs/xpg4.a %t.a +RUN: llvm-ar m %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck %s + +CHECK: evenlen +CHECK-NEXT: oddlen +CHECK-NEXT: IsNAN.o +CHECK-NEXT: very_long_bytecode_file_name.bc + +RUN: rm -f %t.a +RUN: cp %p/Inputs/GNU.a %t.a +RUN: llvm-ar mb evenlen %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck --check-prefix=BEFORE %s + +BEFORE: very_long_bytecode_file_name.bc +BEFORE-NEXT: evenlen +BEFORE-NEXT: oddlen +BEFORE-NEXT: IsNAN.o + +RUN: rm -f %t.a +RUN: cp %p/Inputs/GNU.a %t.a +RUN: llvm-ar ma evenlen %t.a very_long_bytecode_file_name.bc +RUN: llvm-ar t %t.a | FileCheck --check-prefix=AFTER %s + +AFTER: evenlen +AFTER-NEXT: very_long_bytecode_file_name.bc +AFTER-NEXT: oddlen +AFTER-NEXT: IsNAN.o diff --git a/test/Object/archive-replace-pos.test b/test/Object/archive-replace-pos.test new file mode 100644 index 0000000..0acead6 --- /dev/null +++ b/test/Object/archive-replace-pos.test @@ -0,0 +1,30 @@ +Test adding a member to a particular position + +RUN: touch %t.foo +RUN: touch %t.bar +RUN: rm -f %t.a +RUN: llvm-ar rc %t.a %t.foo %t.bar +RUN: touch %t.zed +RUN: llvm-ar rca %t.foo %t.a %t.zed +RUN: llvm-ar t %t.a | FileCheck %s + +CHECK: .foo +CHECK-NEXT: .zed +CHECK-NEXT: .bar + +RUN: rm -f %t.a +RUN: llvm-ar rc %t.a %t.zed %t.foo %t.bar +RUN: llvm-ar t %t.a | FileCheck --check-prefix=CHECK2 %s + +CHECK2: .zed +CHECK2-NEXT: .foo +CHECK2-NEXT: .bar + +RUN: llvm-ar rca %t.foo %t.a %t.zed +RUN: llvm-ar t %t.a | FileCheck --check-prefix=CHECK3 %s +CHECK3: .foo +CHECK3-NEXT: .zed +CHECK3-NEXT: .bar + +RUN: llvm-ar rc %t.a %t.zed +RUN: llvm-ar t %t.a | FileCheck --check-prefix=CHECK3 %s diff --git a/test/Object/archive-symtab.test b/test/Object/archive-symtab.test new file mode 100644 index 0000000..0d2504d --- /dev/null +++ b/test/Object/archive-symtab.test @@ -0,0 +1,50 @@ +RUN: rm -f %t.a +RUN: llvm-ar rcs %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64 +RUN: llvm-nm -s %t.a | FileCheck %s + +CHECK: Archive map +CHECK-NEXT: main in trivial-object-test.elf-x86-64 +CHECK-NEXT: foo in trivial-object-test2.elf-x86-64 +CHECK-NEXT: main in trivial-object-test2.elf-x86-64 +CHECK-NOT: bar + +CHECK: trivial-object-test.elf-x86-64: +CHECK-NEXT: U SomeOtherFunction +CHECK-NEXT: 00000000 T main +CHECK-NEXT: U puts +CHECK-NEXT: trivial-object-test2.elf-x86-64: +CHECK-NEXT: 00000000 t bar +CHECK-NEXT: 00000006 T foo +CHECK-NEXT: 00000016 T main + +RUN: rm -f %t.a +RUN: llvm-ar rcS %t.a %p/Inputs/trivial-object-test.elf-x86-64 %p/Inputs/trivial-object-test2.elf-x86-64 +RUN: llvm-nm -s %t.a | FileCheck %s --check-prefix=NOMAP + +NOMAP-NOT: Archive map + +RUN: llvm-ar s %t.a +RUN: llvm-nm -s %t.a | FileCheck %s + +check that the archive does have a corrupt symbol table. +RUN: rm -f %t.a +RUN: cp %p/Inputs/archive-test.a-corrupt-symbol-table %t.a +RUN: llvm-nm -s %t.a | FileCheck %s --check-prefix=CORRUPT + +CORRUPT: Archive map +CORRUPT-NEXT: mbin in trivial-object-test.elf-x86-64 +CORRUPT-NEXT: foo in trivial-object-test2.elf-x86-64 +CORRUPT-NEXT: main in trivial-object-test2.elf-x86-64 + +CORRUPT: trivial-object-test.elf-x86-64: +CORRUPT-NEXT: U SomeOtherFunction +CORRUPT-NEXT: 00000000 T main +CORRUPT-NEXT: U puts +CORRUPT-NEXT: trivial-object-test2.elf-x86-64: +CORRUPT-NEXT: 00000000 t bar +CORRUPT-NEXT: 00000006 T foo +CORRUPT-NEXT: 00000016 T main + +check that the we *don't* update the symbol table. +RUN: llvm-ar s %t.a +RUN: llvm-nm -s %t.a | FileCheck %s --check-prefix=CORRUPT diff --git a/test/Object/archive-toc.test b/test/Object/archive-toc.test new file mode 100644 index 0000000..0a5e72b --- /dev/null +++ b/test/Object/archive-toc.test @@ -0,0 +1,28 @@ +Test reading an archive created by gnu ar +RUN: env TZ=GMT llvm-ar tv %p/Inputs/GNU.a | FileCheck %s --check-prefix=GNU -strict-whitespace + +GNU: rw-r--r-- 500/500 8 Nov 19 02:57 2004 evenlen +GNU-NEXT: rw-r--r-- 500/500 7 Nov 19 02:57 2004 oddlen +GNU-NEXT: rwxr-xr-x 500/500 1465 Nov 19 03:01 2004 very_long_bytecode_file_name.bc +GNU-NEXT: rw-r--r-- 500/500 2280 Nov 19 03:04 2004 IsNAN.o + + +Test reading an archive createdy by Mac OS X ar +RUN: env TZ=GMT llvm-ar tv %p/Inputs/MacOSX.a | FileCheck %s --check-prefix=OSX -strict-whitespace + +OSX-NOT: __.SYMDEF +OSX: rw-r--r-- 501/501 8 Nov 19 02:57 2004 evenlen +OSX-NEXT: rw-r--r-- 501/501 8 Nov 19 02:57 2004 oddlen +OSX-NEXT: rw-r--r-- 502/502 1465 Feb 4 06:59 2010 very_long_bytecode_file_name.bc +OSX-NEXT: rw-r--r-- 501/501 2280 Nov 19 04:32 2004 IsNAN.o + +Test reading an archive created on Solaris by /usr/ccs/bin/ar +RUN: env TZ=GMT llvm-ar tv %p/Inputs/SVR4.a | FileCheck %s -strict-whitespace + +Test reading an archive created on Solaris by /usr/xpg4/bin/ar +RUN: env TZ=GMT llvm-ar tv %p/Inputs/xpg4.a | FileCheck %s -strict-whitespace + +CHECK: rw-r--r-- 1002/102 8 Nov 19 03:24 2004 evenlen +CHECK-NEXT: rw-r--r-- 1002/102 7 Nov 19 03:24 2004 oddlen +CHECK-NEXT: rwxr-xr-x 1002/102 1465 Nov 19 03:24 2004 very_long_bytecode_file_name.bc +CHECK-NEXT: rw-r--r-- 1002/102 2280 Nov 19 03:24 2004 IsNAN.o diff --git a/test/Object/archive-update.test b/test/Object/archive-update.test new file mode 100644 index 0000000..20286d2 --- /dev/null +++ b/test/Object/archive-update.test @@ -0,0 +1,37 @@ +Test the 'u' option of llvm-ar + +REQUIRES: shell + +RUN: cd %T +RUN: rm -f %t.a + +Create a file named evenlen that is newer than the evenlen on the source dir. +RUN: mkdir -p %t.older +RUN: echo older > %t.older/evenlen + +Either the shell supports the 'touch' command with a flag to manually set the +mtime or we sleep for over a second so that the mtime is definitely observable. +RUN: touch -m -t 200001010000 %t.older/evenlen || sleep 1.1 + +RUN: mkdir -p %t.newer +RUN: echo newer > %t.newer/evenlen +RUN: touch %t.newer/evenlen + +Create an achive with the newest file +RUN: llvm-ar r %t.a %t.newer/evenlen +RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s + +Check that without the 'u' option the member is replaced with an older file. +RUN: llvm-ar r %t.a %t.older/evenlen +RUN: llvm-ar p %t.a | FileCheck --check-prefix=OLDER %s + +Check that with the 'u' option the member is replaced with a newer file. +RUN: llvm-ar ru %t.a %t.newer/evenlen +RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s + +Check that with the 'u' option the member is not replaced with an older file. +RUN: llvm-ar ru %t.a %t.older/evenlen +RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s + +NEWER: newer +OLDER: older diff --git a/test/Object/check_binary_output.ll b/test/Object/check_binary_output.ll new file mode 100644 index 0000000..567f18e --- /dev/null +++ b/test/Object/check_binary_output.ll @@ -0,0 +1,4 @@ +; This is not an assembly file, this is just to run the test. +; The test verifies that llvm-ar produces a binary output. + +;RUN: llvm-ar p %p/Inputs/GNU.a very_long_bytecode_file_name.bc | cmp -s %p/Inputs/very_long_bytecode_file_name.bc - diff --git a/test/Object/directory.ll b/test/Object/directory.ll new file mode 100644 index 0000000..bf8ff32 --- /dev/null +++ b/test/Object/directory.ll @@ -0,0 +1,16 @@ +;RUN: rm -f %T/test.a +;RUN: not llvm-ar r %T/test.a . 2>&1 | FileCheck %s +;CHECK: .: Is a directory + +; Opening a directory works on cygwin and freebsd. +;XFAIL: freebsd, cygwin + +;RUN: rm -f %T/test.a +;RUN: touch %T/a-very-long-file-name +;RUN: llvm-ar r %T/test.a %s %T/a-very-long-file-name +;RUN: llvm-ar r %T/test.a %T/a-very-long-file-name +;RUN: llvm-ar t %T/test.a | FileCheck -check-prefix=MEMBERS %s +;MEMBERS-NOT: / +;MEMBERS: directory.ll +;MEMBERS: a-very-long-file-name +;MEMBERS-NOT: a-very-long-file-name diff --git a/test/Object/extract.ll b/test/Object/extract.ll new file mode 100644 index 0000000..4e519ae --- /dev/null +++ b/test/Object/extract.ll @@ -0,0 +1,46 @@ +; This isn't really an assembly file, its just here to run the test. + +; This test just makes sure that llvm-ar can extract bytecode members +; from various style archives. + +; REQUIRES: shell + +; RUN: cd %T + +; RUN: rm -f very_long_bytecode_file_name.bc +; RUN: llvm-ar p %p/Inputs/GNU.a very_long_bytecode_file_name.bc | \ +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc - +; RUN: llvm-ar x %p/Inputs/GNU.a very_long_bytecode_file_name.bc +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc \ +; RUN: very_long_bytecode_file_name.bc + +; RUN: rm -f very_long_bytecode_file_name.bc +; RUN: llvm-ar p %p/Inputs/MacOSX.a very_long_bytecode_file_name.bc | \ +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc - +; RUN: llvm-ar x %p/Inputs/MacOSX.a very_long_bytecode_file_name.bc +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc \ +; RUN: very_long_bytecode_file_name.bc + +; RUN: rm -f very_long_bytecode_file_name.bc +; RUN: llvm-ar p %p/Inputs/SVR4.a very_long_bytecode_file_name.bc | \ +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc - +; RUN: llvm-ar x %p/Inputs/SVR4.a very_long_bytecode_file_name.bc +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc \ +; RUN: very_long_bytecode_file_name.bc + +; RUN: rm -f very_long_bytecode_file_name.bc +; RUN: llvm-ar p %p/Inputs/xpg4.a very_long_bytecode_file_name.bc |\ +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc - +; RUN: llvm-ar x %p/Inputs/xpg4.a very_long_bytecode_file_name.bc +; RUN: cmp -s %p/Inputs/very_long_bytecode_file_name.bc \ +; RUN: very_long_bytecode_file_name.bc + + +; Test that the 'o' option is working by extracting a file, putting it in o +; new archive and checking that date. +; RUN: rm -f very_long_bytecode_file_name.bc +; RUN: llvm-ar xo %p/Inputs/GNU.a very_long_bytecode_file_name.bc +; RUN: llvm-ar rc %t.a very_long_bytecode_file_name.bc +; RUN: env TZ=GMT llvm-ar tv %t.a | FileCheck %s + +CHECK: 1465 Nov 19 03:01 2004 very_long_bytecode_file_name.bc diff --git a/test/Object/lit.local.cfg b/test/Object/lit.local.cfg index b2439b2..d74d039 100644 --- a/test/Object/lit.local.cfg +++ b/test/Object/lit.local.cfg @@ -1 +1 @@ -config.suffixes = ['.test', '.ll'] +config.suffixes = ['.test', '.ll', '.yaml'] diff --git a/test/Object/nm-archive.test b/test/Object/nm-archive.test index 2d96b73..0d43cc7 100644 --- a/test/Object/nm-archive.test +++ b/test/Object/nm-archive.test @@ -1,9 +1,5 @@ RUN: llvm-nm %p/Inputs/archive-test.a-coff-i386 \ RUN: | FileCheck %s -check-prefix COFF -RUN: llvm-as %p/Inputs/trivial.ll -o=%t1 -RUN: llvm-ar rcs %t2 %t1 -RUN: llvm-nm %t2 | FileCheck %s -check-prefix BITCODE - COFF: trivial-object-test.coff-i386: COFF-NEXT: 00000000 d .data @@ -13,6 +9,27 @@ COFF-NEXT: U _SomeOtherFunction COFF-NEXT: 00000000 T _main COFF-NEXT: 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 + BITCODE: U SomeOtherFunction BITCODE-NEXT: T main BITCODE-NEXT: U puts + + +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 -s %p/Inputs/archive-test.a-gnu-minimal + +Don't reject an empty archive. +RUN: llvm-nm %p/Inputs/archive-test.a-empty diff --git a/test/Object/nm-error.test b/test/Object/nm-error.test new file mode 100644 index 0000000..146b887 --- /dev/null +++ b/test/Object/nm-error.test @@ -0,0 +1,17 @@ +Test that llvm-nm returns an error because of the unknown file type, but +keeps processing subsequent files. + +Note: We use a temporary file since the tests don't run with pipefail. + +RUN: touch %t +RUN: not llvm-nm %p/Inputs/trivial-object-test.elf-i386 %t \ +RUN: %p/Inputs/trivial-object-test.elf-i386 > %t.log +RUN: FileCheck %s < %t.log + +CHECK: U SomeOtherFunction +CHECK: 00000000 T main +CHECK: U puts + +CHECK: U SomeOtherFunction +CHECK: 00000000 T main +CHECK: U puts diff --git a/test/Object/nm-trivial-object.test b/test/Object/nm-trivial-object.test index 5c3cc31..d517745 100644 --- a/test/Object/nm-trivial-object.test +++ b/test/Object/nm-trivial-object.test @@ -18,6 +18,7 @@ COFF: U {{_?}}SomeOtherFunction COFF: 00000000 T {{_?}}main COFF: U {{_?}}puts +ELF-NOT: U ELF: U SomeOtherFunction ELF: 00000000 T main ELF: U puts diff --git a/test/Object/nm-universal-binary.test b/test/Object/nm-universal-binary.test new file mode 100644 index 0000000..8febfdf --- /dev/null +++ b/test/Object/nm-universal-binary.test @@ -0,0 +1,6 @@ +RUN: llvm-nm %p/Inputs/macho-universal.x86_64.i386 | FileCheck %s + +CHECK: macho-universal.x86_64.i386:x86_64 +CHECK: main +CHECK: macho-universal.x86_64.i386:i386 +CHECK: main diff --git a/test/Object/yaml2obj-elf-file-headers.yaml b/test/Object/yaml2obj-elf-file-headers.yaml new file mode 100644 index 0000000..2851701 --- /dev/null +++ b/test/Object/yaml2obj-elf-file-headers.yaml @@ -0,0 +1,11 @@ +# RUN: yaml2obj -format=elf %s | llvm-readobj -file-headers - | FileCheck %s +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + OSABI: ELFOSABI_GNU + Type: ET_REL + Machine: EM_X86_64 + +# CHECK: OS/ABI: GNU/Linux +# CHECK: Type: Relocatable diff --git a/test/Object/yaml2obj-elf-section-basic.yaml b/test/Object/yaml2obj-elf-section-basic.yaml new file mode 100644 index 0000000..34be11d --- /dev/null +++ b/test/Object/yaml2obj-elf-section-basic.yaml @@ -0,0 +1,35 @@ +# RUN: yaml2obj -format=elf %s | llvm-readobj -sections -section-data - | FileCheck %s +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0xCAFEBABE + Link: .text # Doesn't make sense for SHT_PROGBITS, but good enough for test. + Content: EBFE + AddressAlign: 2 + +# CHECK: Section { +# CHECK: Index: 0 +# CHECK: Type: SHT_NULL (0x0) +# +# CHECK: Section { +# CHECK: Name: .text +# CHECK: Type: SHT_PROGBITS (0x1) +# CHECK-NEXT: Flags [ (0x6) +# CHECK-NEXT: SHF_ALLOC (0x2) +# CHECK-NEXT: SHF_EXECINSTR (0x4) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0xCAFEBABE +# CHECK: Size: 2 +# Check that Link != 0. +# CHECK: Link: {{[1-9][0-9]*}} +# CHECK: AddressAlignment: 2 +# CHECK: SectionData ( +# CHECK-NEXT: 0000: EBFE +# CHECK-NEXT: ) diff --git a/test/Object/yaml2obj-elf-symbol-LocalGlobalWeak.yaml b/test/Object/yaml2obj-elf-symbol-LocalGlobalWeak.yaml new file mode 100644 index 0000000..3c4e830 --- /dev/null +++ b/test/Object/yaml2obj-elf-symbol-LocalGlobalWeak.yaml @@ -0,0 +1,37 @@ +# RUN: yaml2obj -format=elf %s | llvm-readobj -symbols - | FileCheck %s +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_WRITE ] + Content: "DEADBEEF" +Symbols: + Local: + - Name: local_symbol + Type: STT_OBJECT + Section: .data + Global: + - Name: global_symbol + Type: STT_OBJECT + Section: .data + Weak: + - Name: weak_symbol + Type: STT_OBJECT + Section: .data + +# CHECK: Symbol { +# CHECK: Name: (0) +# CHECK: Symbol { +# CHECK: Name: local_symbol +# CHECK: Binding: Local +# CHECK: Symbol { +# CHECK: Name: global_symbol +# CHECK: Binding: Global +# CHECK: Symbol { +# CHECK: Name: weak_symbol +# CHECK: Binding: Weak diff --git a/test/Object/yaml2obj-elf-symbol-basic.yaml b/test/Object/yaml2obj-elf-symbol-basic.yaml new file mode 100644 index 0000000..3fb9b17 --- /dev/null +++ b/test/Object/yaml2obj-elf-symbol-basic.yaml @@ -0,0 +1,40 @@ +# RUN: yaml2obj -format=elf %s | llvm-readobj -symbols - | FileCheck %s +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: "90EBFE" # x86 machine code + # NOP ; To make main's `Value` non-zero (for testing). + # main: + # JMP -2 ; (infloop) + # This YAML file is a valid relocatable object that, + # when linked and run on x86_64, will go into an + # infloop. +Symbols: + Global: + - Name: main + Type: STT_FUNC + Section: .text + Value: 0x1 + Size: 2 + - Name: undefined_symbol + +# CHECK: Symbols [ +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: (0) +# CHECK: Symbol { +# CHECK-NEXT: Name: main +# CHECK-NEXT: Value: 0x1 +# CHECK-NEXT: Size: 2 +# CHECK: Binding: Global +# CHECK-NEXT: Type: Function +# CHECK: Section: .text +# CHECK: Symbol { +# CHECK: Name: undefined_symbol +# CHECK: Section: (0x0) |