152 lines · plain
1# RUN: yaml2obj %s -o %t2# RUN: cp %t %t33# RUN: llvm-objcopy --strip-debug %t %t24# RUN: llvm-readobj --file-headers --sections --symbols %t2 | FileCheck %s5 6# Verify that the previous run of llvm-objcopy has not modified the input.7# RUN: cmp %t %t38 9# RUN: llvm-objcopy -g %t %t2g10# Verify that --strip-debug and -g produce the same output11# RUN: cmp %t2 %t2g12 13# RUN: llvm-strip --strip-debug %t314# RUN: cmp %t2 %t315 16# RUN: cp %t %t417# RUN: llvm-strip -d %t418# RUN: cmp %t2 %t419 20# RUN: cp %t %t521# RUN: llvm-strip -g %t522# RUN: cmp %t2 %t523 24# RUN: cp %t %t625# RUN: llvm-strip -S %t626# RUN: cmp %t2 %t627 28# RUN: rm -f %t.a29# RUN: llvm-ar crs %t.a %t30# RUN: llvm-objcopy --strip-debug %t.a %t.a31# RUN: llvm-ar p %t.a > %t732# RUN: cmp %t2 %t733 34# Verify that an archive with multiple object files is handled correctly.35# RUN: cp %t %t.duplicate36# RUN: cp %t2 %t.duplicate.stripped37# RUN: rm -f %t.multiple-stripped-obj.a38# RUN: llvm-ar crs %t.multiple-stripped-obj.a %t2 %t.duplicate.stripped39# RUN: rm -f %t.multiple-obj.a40# RUN: llvm-ar crs %t.multiple-obj.a %t %t.duplicate41# RUN: llvm-objcopy --strip-debug %t.multiple-obj.a %t.multiple-obj.stripped.a42# RUN: llvm-ar p %t.multiple-stripped-obj.a > %t.multiple-stripped-obj.a.dump43# RUN: llvm-ar p %t.multiple-obj.stripped.a > %t.multiple-obj.stripped.a.dump44# RUN: cmp %t.multiple-stripped-obj.a.dump %t.multiple-obj.stripped.a.dump45 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.o49# RUN: cp %s %t2.txt50# RUN: cp %t %t3.o51# RUN: rm -f %t.non-object.a52# RUN: llvm-ar cr %t.non-object.a %t1.o %t2.txt %t3.o53# RUN: llvm-ar t %t.non-object.a | FileCheck %s --check-prefix=NON-OBJECT-ARCHIVE-MEMBERS54 55# NON-OBJECT-ARCHIVE-MEMBERS: 1.o56# NON-OBJECT-ARCHIVE-MEMBERS-NEXT: 2.txt57# NON-OBJECT-ARCHIVE-MEMBERS-NEXT: 3.o58 59# RUN: cp %t.non-object.a %t.non-object.copy.a60# RUN: not llvm-objcopy --strip-debug %t.non-object.a %t2.non-object.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT61 62# BAD-FORMAT: The file was not recognized as a valid object file63 64# Verify that %t.non-object.a has not been modified.65# RUN: cmp %t.non-object.a %t.non-object.copy.a66 67# RUN: rm -f %t.thin.a68# Copy %t to %t.thin.archive.member to avoid changing %t directly.69# RUN: cp %t %t.thin.archive.member70# RUN: llvm-ar crsT %t.thin.a %t.thin.archive.member71# RUN: llvm-objcopy --strip-debug %t.thin.a %t2.thin.a72# RUN: cat %t.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE73# RUN: cat %t2.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE74 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.member79 80# RUN: rm -f %t.non-object.thin.a81# RUN: llvm-ar crsT %t.non-object.thin.a %t1.o %t2.txt %t3.o82# RUN: cp %t.non-object.thin.a %t.non-object.thin.copy.a83# RUN: not llvm-objcopy --strip-debug %t.non-object.thin.a %t.non-object.thin.a 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT84 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.a87# RUN: cmp %t %t1.o88# RUN: cmp %s %t2.txt89# RUN: cmp %t %t3.o90 91!ELF92FileHeader:93 Class: ELFCLASS6494 Data: ELFDATA2LSB95 Type: ET_REL96 Machine: EM_X86_6497Sections:98 - Name: .debugfoo99 Type: SHT_PROGBITS100 Content: "00000000"101 ## .zdebug is no longer recognized as a debug section.102 - Name: .zdebugfoo103 Type: SHT_PROGBITS104 Content: "00000000"105 - Name: .gdb_index106 Type: SHT_PROGBITS107 Content: "00000000"108 - Name: .text109 Type: SHT_PROGBITS110 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]111 AddressAlign: 0x0000000000000010112 Content: "00000000"113Symbols:114 - Name: foo115 Section: .text116 Binding: STB_GLOBAL117 - Name: debugfoo118 Section: .debugfoo119 Binding: STB_GLOBAL120 - Name: filesymbol121 Type: STT_FILE122 123# CHECK: SectionHeaderCount: 6124 125# CHECK: Name: .zdebugfoo126# CHECK: Name: .text127# CHECK: Name: .symtab128# CHECK: Name: .strtab129# CHECK: Name: .shstrtab130 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: Undefined141# CHECK-NEXT: }142# CHECK-NEXT: Symbol {143# CHECK-NEXT: Name: foo144# CHECK-NEXT: Value:145# CHECK-NEXT: Size:146# CHECK-NEXT: Binding: Global147# CHECK-NEXT: Type:148# CHECK-NEXT: Other:149# CHECK-NEXT: Section: .text150# CHECK-NEXT: }151# CHECK-NEXT: ]152