diff options
Diffstat (limited to 'llvm/test')
4 files changed, 169 insertions, 1 deletions
diff --git a/llvm/test/tools/llvm-objcopy/basic-archive-copy.test b/llvm/test/tools/llvm-objcopy/basic-archive-copy.test new file mode 100644 index 00000000000..bc050c3c70d --- /dev/null +++ b/llvm/test/tools/llvm-objcopy/basic-archive-copy.test @@ -0,0 +1,99 @@ +# RUN: yaml2obj %s > %t + +# RUN: rm -f %t.a +# RUN: llvm-ar crs %t.a %t +# RUN: cp %t.a %t.copy.a +# RUN: llvm-objcopy %t.a %t2.a +# RUN: llvm-objcopy %t %t2 +# RUN: llvm-ar p %t2.a > %t3 +# RUN: cmp %t2 %t3 + +# RUN: llvm-readobj -sections %t2 | FileCheck %s +# RUN: llvm-nm -print-armap %t.a | FileCheck --check-prefix=INDEX-TABLE %s +# RUN: llvm-nm -print-armap %t2.a | FileCheck --check-prefix=INDEX-TABLE %s +# Verify that llvm-objcopy has not modifed the input. +# RUN: cmp %t.copy.a %t.a + +# INDEX-TABLE: Archive map +# INDEX-TABLE-NEXT: foo in + +# RUN: rm -f %t.no.index.a +# RUN: llvm-ar crS %t.no.index.a %t +# RUN: llvm-objcopy %t.no.index.a %t2.no.index.a +# RUN: llvm-ar p %t2.no.index.a > %t4 + +# RUN: llvm-nm -print-armap %t.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s +# RUN: llvm-nm -print-armap %t2.no.index.a | FileCheck --check-prefix=NO-INDEX-TABLE %s +# RUN: cmp %t2 %t4 + +# NO-INDEX-TABLE-NOT: Archive map +# NO-INDEX-TABLE-NOT: foo in + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +Sections: + - Name: .bss + Type: SHT_NOBITS + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000010 + Size: 64 + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + AddressAlign: 0x0000000000000010 + Content: "00000000" +Symbols: + Global: + - Name: foo + Type: STT_FUNC + Section: .text + Value: 0x1004 + +# CHECK: Type: SHT_NULL + +# CHECK: Name: .bss +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: 64 + +# CHECK: Name: .text +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_EXECINSTR +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: 4 + +# CHECK: Name: .symtab +# CHECK-NEXT: Type: SHT_SYMTAB +# CHECK-NEXT: Flags [ (0x0) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: 48 + +# CHECK: Name: .strtab +# CHECK-NEXT: Type: SHT_STRTAB +# CHECK-NEXT: Flags [ (0x0) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: 6 + +# CHECK: Name: .shstrtab +# CHECK-NEXT: Type: SHT_STRTAB +# CHECK-NEXT: Flags [ +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: 38 diff --git a/llvm/test/tools/llvm-objcopy/fail-no-output-directory.test b/llvm/test/tools/llvm-objcopy/fail-no-output-directory.test index 89bf62d3556..f66b2e09fce 100644 --- a/llvm/test/tools/llvm-objcopy/fail-no-output-directory.test +++ b/llvm/test/tools/llvm-objcopy/fail-no-output-directory.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s > %t # RUN: not llvm-objcopy %t no/such/dir 2>&1 | FileCheck %s -# CHECK: failed to open no/such/dir +# CHECK: failed to open no/such/dir: !ELF FileHeader: diff --git a/llvm/test/tools/llvm-objcopy/strip-all.test b/llvm/test/tools/llvm-objcopy/strip-all.test index 2e935526953..d650ab790b8 100644 --- a/llvm/test/tools/llvm-objcopy/strip-all.test +++ b/llvm/test/tools/llvm-objcopy/strip-all.test @@ -21,6 +21,12 @@ # RUN: cmp %t2 %t-should-be-stripped # RUN: cmp %t %t-should-remain-the-same +# RUN: rm -f %t.a +# RUN: llvm-ar crs %t.a %t +# RUN: llvm-objcopy --strip-all %t.a %t.a +# RUN: llvm-ar p %t.a > %t6 +# RUN: cmp %t2 %t6 + !ELF FileHeader: Class: ELFCLASS64 diff --git a/llvm/test/tools/llvm-objcopy/strip-debug.test b/llvm/test/tools/llvm-objcopy/strip-debug.test index 4c217f1d946..c8f90d9ca19 100644 --- a/llvm/test/tools/llvm-objcopy/strip-debug.test +++ b/llvm/test/tools/llvm-objcopy/strip-debug.test @@ -21,6 +21,69 @@ # RUN: llvm-strip -S %t6 # RUN: cmp %t2 %t6 +# RUN: rm -f %t.a +# RUN: llvm-ar crs %t.a %t +# RUN: llvm-objcopy --strip-debug %t.a %t.a +# RUN: llvm-ar p %t.a > %t7 +# RUN: cmp %t2 %t7 + +# Verify that an archive with multiple object files is handled correctly. +# RUN: cp %t %t.duplicate +# RUN: cp %t2 %t.duplicate.stripped +# RUN: rm -f %t.multiple-stripped-obj.a +# RUN: llvm-ar crs %t.multiple-stripped-obj.a %t2 %t.duplicate.stripped +# RUN: rm -f %t.multiple-obj.a +# RUN: llvm-ar crs %t.multiple-obj.a %t %t.duplicate +# RUN: llvm-objcopy --strip-debug %t.multiple-obj.a %t.multiple-obj.stripped.a +# RUN: llvm-ar p %t.multiple-stripped-obj.a > %t.multiple-stripped-obj.a.dump +# RUN: llvm-ar p %t.multiple-obj.stripped.a > %t.multiple-obj.stripped.a.dump +# RUN: cmp %t.multiple-stripped-obj.a.dump %t.multiple-obj.stripped.a.dump + +# We can not use %t inside the patterns passed to FileCheck, +# thus we have to use "recognizable" file names. +# RUN: cp %t %t1.o +# RUN: cp %s %t2.txt +# RUN: cp %t %t3.o +# RUN: rm -f %t.non-object.a +# RUN: llvm-ar cr %t.non-object.a %t1.o %t2.txt %t3.o +# RUN: llvm-ar t %t.non-object.a | FileCheck %s --check-prefix=NON-OBJECT-ARCHIVE-MEMBERS + +# NON-OBJECT-ARCHIVE-MEMBERS: 1.o +# NON-OBJECT-ARCHIVE-MEMBERS-NEXT: 2.txt +# NON-OBJECT-ARCHIVE-MEMBERS-NEXT: 3.o + +# RUN: cp %t.non-object.a %t.non-object.copy.a +# RUN: not llvm-objcopy --strip-debug %t.non-object.a %t2.non-object.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT + +# BAD-FORMAT: The file was not recognized as a valid object file + +# Verify that %t.non-object.a has not been modified. +# RUN: cmp %t.non-object.a %t.non-object.copy.a + +# RUN: rm -f %t.thin.a +# Copy %t to %t.thin.archive.member to avoid changing %t directly. +# RUN: cp %t %t.thin.archive.member +# RUN: llvm-ar crsT %t.thin.a %t.thin.archive.member +# RUN: llvm-objcopy --strip-debug %t.thin.a %t2.thin.a +# RUN: cat %t.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE +# RUN: cat %t2.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE + +# VERIFY-THIN-ARCHIVE: !<thin> + +# Verify that the member of a thin archive was properly modified. +# RUN: cmp %t2 %t.thin.archive.member + +# RUN: rm -f %t.non-object.thin.a +# RUN: llvm-ar crsT %t.non-object.thin.a %t1.o %t2.txt %t3.o +# RUN: cp %t.non-object.thin.a %t.non-object.thin.copy.a +# RUN: not llvm-objcopy --strip-debug %t.non-object.thin.a %t.non-object.thin.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT + +# Verify that in the case of error thin archive and its memebers are not getting modified. +# RUN: cmp %t.non-object.thin.a %t.non-object.thin.copy.a +# RUN: cmp %t %t1.o +# RUN: cmp %s %t2.txt +# RUN: cmp %t %t3.o + !ELF FileHeader: Class: ELFCLASS64 |

