| 1 |
# RUN: yaml2obj %s -o %t |
| 2 |
# RUN: cp %t %t3 |
| 3 |
# RUN: llvm-objcopy --strip-debug %t %t2 |
| 4 |
# RUN: llvm-readobj --file-headers --sections --symbols %t2 | FileCheck %s |
| 5 |
|
| 6 |
# Verify that the previous run of llvm-objcopy has not modified the input. |
| 7 |
# RUN: cmp %t %t3 |
| 8 |
|
| 9 |
# RUN: llvm-objcopy -g %t %t2g |
| 10 |
# Verify that --strip-debug and -g produce the same output |
| 11 |
# RUN: cmp %t2 %t2g |
| 12 |
|
| 13 |
# RUN: llvm-strip --strip-debug %t3 |
| 14 |
# RUN: cmp %t2 %t3 |
| 15 |
|
| 16 |
# RUN: cp %t %t4 |
| 17 |
# RUN: llvm-strip -d %t4 |
| 18 |
# RUN: cmp %t2 %t4 |
| 19 |
|
| 20 |
# RUN: cp %t %t5 |
| 21 |
# RUN: llvm-strip -g %t5 |
| 22 |
# RUN: cmp %t2 %t5 |
| 23 |
|
| 24 |
# RUN: cp %t %t6 |
| 25 |
# RUN: llvm-strip -S %t6 |
| 26 |
# RUN: cmp %t2 %t6 |
| 27 |
|
| 28 |
# RUN: rm -f %t.a |
| 29 |
# RUN: llvm-ar crs %t.a %t |
| 30 |
# RUN: llvm-objcopy --strip-debug %t.a %t.a |
| 31 |
# RUN: llvm-ar p %t.a > %t7 |
| 32 |
# RUN: cmp %t2 %t7 |
| 33 |
|
| 34 |
# Verify that an archive with multiple object files is handled correctly. |
| 35 |
# RUN: cp %t %t.duplicate |
| 36 |
# RUN: cp %t2 %t.duplicate.stripped |
| 37 |
# RUN: rm -f %t.multiple-stripped-obj.a |
| 38 |
# RUN: llvm-ar crs %t.multiple-stripped-obj.a %t2 %t.duplicate.stripped |
| 39 |
# RUN: rm -f %t.multiple-obj.a |
| 40 |
# RUN: llvm-ar crs %t.multiple-obj.a %t %t.duplicate |
| 41 |
# RUN: llvm-objcopy --strip-debug %t.multiple-obj.a %t.multiple-obj.stripped.a |
| 42 |
# RUN: llvm-ar p %t.multiple-stripped-obj.a > %t.multiple-stripped-obj.a.dump |
| 43 |
# RUN: llvm-ar p %t.multiple-obj.stripped.a > %t.multiple-obj.stripped.a.dump |
| 44 |
# RUN: cmp %t.multiple-stripped-obj.a.dump %t.multiple-obj.stripped.a.dump |
| 45 |
|
| 46 |
# We can not use %t inside the patterns passed to FileCheck, |
| 47 |
# thus we have to use "recognizable" file names. |
| 48 |
# RUN: cp %t %t1.o |
| 49 |
# RUN: cp %s %t2.txt |
| 50 |
# RUN: cp %t %t3.o |
| 51 |
# RUN: rm -f %t.non-object.a |
| 52 |
# RUN: llvm-ar cr %t.non-object.a %t1.o %t2.txt %t3.o |
| 53 |
# RUN: llvm-ar t %t.non-object.a | FileCheck %s --check-prefix=NON-OBJECT-ARCHIVE-MEMBERS |
| 54 |
|
| 55 |
# NON-OBJECT-ARCHIVE-MEMBERS: 1.o |
| 56 |
# NON-OBJECT-ARCHIVE-MEMBERS-NEXT: 2.txt |
| 57 |
# NON-OBJECT-ARCHIVE-MEMBERS-NEXT: 3.o |
| 58 |
|
| 59 |
# RUN: cp %t.non-object.a %t.non-object.copy.a |
| 60 |
# RUN: not llvm-objcopy --strip-debug %t.non-object.a %t2.non-object.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT |
| 61 |
|
| 62 |
# BAD-FORMAT: The file was not recognized as a valid object file |
| 63 |
|
| 64 |
# Verify that %t.non-object.a has not been modified. |
| 65 |
# RUN: cmp %t.non-object.a %t.non-object.copy.a |
| 66 |
|
| 67 |
# RUN: rm -f %t.thin.a |
| 68 |
# Copy %t to %t.thin.archive.member to avoid changing %t directly. |
| 69 |
# RUN: cp %t %t.thin.archive.member |
| 70 |
# RUN: llvm-ar crsT %t.thin.a %t.thin.archive.member |
| 71 |
# RUN: llvm-objcopy --strip-debug %t.thin.a %t2.thin.a |
| 72 |
# RUN: cat %t.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE |
| 73 |
# RUN: cat %t2.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE |
| 74 |
|
| 75 |
# VERIFY-THIN-ARCHIVE: !<thin> |
| 76 |
|
| 77 |
# Verify that the member of a thin archive was properly modified. |
| 78 |
# RUN: cmp %t2 %t.thin.archive.member |
| 79 |
|
| 80 |
# RUN: rm -f %t.non-object.thin.a |
| 81 |
# RUN: llvm-ar crsT %t.non-object.thin.a %t1.o %t2.txt %t3.o |
| 82 |
# RUN: cp %t.non-object.thin.a %t.non-object.thin.copy.a |
| 83 |
# RUN: not llvm-objcopy --strip-debug %t.non-object.thin.a %t.non-object.thin.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT |
| 84 |
|
| 85 |
# Verify that in the case of error thin archive and its memebers are not getting modified. |
| 86 |
# RUN: cmp %t.non-object.thin.a %t.non-object.thin.copy.a |
| 87 |
# RUN: cmp %t %t1.o |
| 88 |
# RUN: cmp %s %t2.txt |
| 89 |
# RUN: cmp %t %t3.o |
| 90 |
|
| 91 |
!ELF |
| 92 |
FileHeader: |
| 93 |
Class: ELFCLASS64 |
| 94 |
Data: ELFDATA2LSB |
| 95 |
Type: ET_REL |
| 96 |
Machine: EM_X86_64 |
| 97 |
Sections: |
| 98 |
- Name: .debugfoo |
| 99 |
Type: SHT_PROGBITS |
| 100 |
Content: "00000000" |
| 101 |
## .zdebug is no longer recognized as a debug section. |
| 102 |
- Name: .zdebugfoo |
| 103 |
Type: SHT_PROGBITS |
| 104 |
Content: "00000000" |
| 105 |
- Name: .gdb_index |
| 106 |
Type: SHT_PROGBITS |
| 107 |
Content: "00000000" |
| 108 |
- Name: .text |
| 109 |
Type: SHT_PROGBITS |
| 110 |
Flags: [ SHF_ALLOC, SHF_EXECINSTR ] |
| 111 |
AddressAlign: 0x0000000000000010 |
| 112 |
Content: "00000000" |
| 113 |
Symbols: |
| 114 |
- Name: foo |
| 115 |
Section: .text |
| 116 |
Binding: STB_GLOBAL |
| 117 |
- Name: debugfoo |
| 118 |
Section: .debugfoo |
| 119 |
Binding: STB_GLOBAL |
| 120 |
- Name: filesymbol |
| 121 |
Type: STT_FILE |
| 122 |
|
| 123 |
# CHECK: SectionHeaderCount: 6 |
| 124 |
|
| 125 |
# CHECK: Name: .zdebugfoo |
| 126 |
# CHECK: Name: .text |
| 127 |
# CHECK: Name: .symtab |
| 128 |
# CHECK: Name: .strtab |
| 129 |
# CHECK: Name: .shstrtab |
| 130 |
|
| 131 |
# Check that *only* foo is copied and not debugfoo or filesymbol. |
| 132 |
# CHECK: Symbols [ |
| 133 |
# CHECK-NEXT: Symbol { |
| 134 |
# CHECK-NEXT: Name: |
| 135 |
# CHECK-NEXT: Value: |
| 136 |
# CHECK-NEXT: Size: |
| 137 |
# CHECK-NEXT: Binding: |
| 138 |
# CHECK-NEXT: Type: |
| 139 |
# CHECK-NEXT: Other: |
| 140 |
# CHECK-NEXT: Section: Undefined |
| 141 |
# CHECK-NEXT: } |
| 142 |
# CHECK-NEXT: Symbol { |
| 143 |
# CHECK-NEXT: Name: foo |
| 144 |
# CHECK-NEXT: Value: |
| 145 |
# CHECK-NEXT: Size: |
| 146 |
# CHECK-NEXT: Binding: Global |
| 147 |
# CHECK-NEXT: Type: |
| 148 |
# CHECK-NEXT: Other: |
| 149 |
# CHECK-NEXT: Section: .text |
| 150 |
# CHECK-NEXT: } |
| 151 |
# CHECK-NEXT: ] |