179 lines · plain
1# RUN: yaml2obj %s -o %t2# RUN: cp %t %t13# RUN: llvm-objcopy --strip-unneeded %t %t24## Verify that llvm-objcopy has not modified the input.5# RUN: cmp %t %t16# RUN: llvm-readobj --symbols %t2 | FileCheck %s7 8## Verify that --keep-file-symbols works together with --strip-unneeded9# RUN: llvm-objcopy --keep-file-symbols --strip-unneeded %t %t2b10# RUN: llvm-readobj --symbols %t2b | FileCheck %s --check-prefixes=CHECK,FILESYM11 12# RUN: llvm-objcopy --strip-unneeded-symbol=bar \13# RUN: %t %t314# RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefixes=STRIP-BAR,REMAIN15 16# RUN: llvm-objcopy --regex --strip-unneeded-symbol='.*' %t %t417# RUN: cmp %t2 %t418 19## Verify that --strip-unneeded-symbols removes all unneeded symbols listed in20## the file, but not those that aren't.21## In this case, fileSymbol isn't mentioned (so isn't removed), barbaz is22## mentioned, but isn't removed (because it is needed) and bar, foobar and23## foobaz are mentioned and removed.24# RUN: echo " bar # bar " > %t.list.txt25# RUN: echo "foobar" >> %t.list.txt26# RUN: echo "foobaz" >> %t.list.txt27# RUN: echo " # comment " >> %t.list.txt28# RUN: echo "barbaz" >> %t.list.txt29# RUN: llvm-objcopy --strip-unneeded-symbols %t.list.txt %t %t530# RUN: cmp %t2b %t531 32# RUN: echo " .* # * - remove all " > %t.list2.txt33# RUN: llvm-objcopy --regex --strip-unneeded-symbols %t.list2.txt %t %t634# RUN: cmp %t2 %t635 36## Verify that llvm-strip modifies the symbol table the same way.37# RUN: llvm-strip --strip-unneeded %t38# RUN: cmp %t %t239 40!ELF41FileHeader:42 Class: ELFCLASS6443 Data: ELFDATA2LSB44 Type: ET_REL45 Machine: EM_X86_6446Sections:47 - Name: .text48 Type: SHT_PROGBITS49 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]50 Address: 0x100051 AddressAlign: 0x000000000000001052 Size: 6453 - Name: .group54 Type: SHT_GROUP55 Link: .symtab56 AddressAlign: 0x000000000000000457 Info: barfoo58 Members:59 - SectionOrType: GRP_COMDAT60 - SectionOrType: .text61 - Name: .rel.text62 Type: SHT_REL63 Link: .symtab64 Info: .text65 Relocations:66 - Offset: 0x100067 Symbol: foo68 Type: R_X86_64_PC3269Symbols:70 - Name: foo71 Type: STT_FUNC72 Section: .text73 Value: 0x100074 Size: 875 - Name: bar76 Type: STT_FUNC77 Size: 878 Section: .text79 Value: 0x100880 - Name: barfoo81 Type: STT_FUNC82 Size: 883 Section: .text84 Value: 0x101085 - Name: fileSymbol86 Type: STT_FILE87 Index: SHN_ABS88 - Name: sectionSymbol89 Type: STT_SECTION90 - Name: foobar91 Type: STT_FUNC92 Binding: STB_GLOBAL93 - Name: barbaz94 Type: STT_FUNC95 Size: 896 Section: .text97 Value: 0x102098 Binding: STB_GLOBAL99 - Name: baz100 Type: STT_FUNC101 Size: 8102 Section: .text103 Value: 0x1018104 Binding: STB_WEAK105 - Name: foobaz106 Type: STT_FUNC107 Binding: STB_WEAK108 109#CHECK: Symbols [110#CHECK-NEXT: Symbol {111#CHECK-NEXT: Name:112#CHECK-NEXT: Value: 0x0113#CHECK-NEXT: Size: 0114#CHECK-NEXT: Binding: Local115#CHECK-NEXT: Type: None116#CHECK-NEXT: Other: 0117#CHECK-NEXT: Section: Undefined118#CHECK-NEXT: }119#CHECK-NEXT: Symbol {120#CHECK-NEXT: Name: foo121#CHECK-NEXT: Value: 0x1000122#CHECK-NEXT: Size: 8123#CHECK-NEXT: Binding: Local124#CHECK-NEXT: Type: Function125#CHECK-NEXT: Other: 0126#CHECK-NEXT: Section: .text127#CHECK-NEXT: }128#CHECK-NEXT: Symbol {129#CHECK-NEXT: Name: barfoo130#CHECK-NEXT: Value: 0x1010131#CHECK-NEXT: Size: 8132#CHECK-NEXT: Binding: Local133#CHECK-NEXT: Type: Function134#CHECK-NEXT: Other: 0135#CHECK-NEXT: Section: .text136#CHECK-NEXT: }137#FILESYM-NEXT:Symbol {138#FILESYM-NEXT: Name: fileSymbol139#FILESYM-NEXT: Value: 0x0140#FILESYM-NEXT: Size: 0141#FILESYM-NEXT: Binding: Local142#FILESYM-NEXT: Type: File143#FILESYM-NEXT: Other: 0144#FILESYM-NEXT: Section: Absolute145#FILESYM-NEXT:}146#CHECK-NEXT: Symbol {147#CHECK-NEXT: Name: sectionSymbol148#CHECK-NEXT: Value: 0x0149#CHECK-NEXT: Size: 0150#CHECK-NEXT: Binding: Local151#CHECK-NEXT: Type: Section152#CHECK-NEXT: Other: 0153#CHECK-NEXT: Section: Undefined154#CHECK-NEXT: }155#CHECK-NEXT: Symbol {156#CHECK-NEXT: Name: barbaz157#CHECK-NEXT: Value: 0x1020158#CHECK-NEXT: Size: 8159#CHECK-NEXT: Binding: Global160#CHECK-NEXT: Type: Function161#CHECK-NEXT: Other: 0162#CHECK-NEXT: Section: .text163#CHECK-NEXT: }164#CHECK-NEXT: Symbol {165#CHECK-NEXT: Name: baz166#CHECK-NEXT: Value: 0x1018167#CHECK-NEXT: Size: 8168#CHECK-NEXT: Binding: Weak169#CHECK-NEXT: Type: Function170#CHECK-NEXT: Other: 0171#CHECK-NEXT: Section: .text172#CHECK-NEXT: }173#CHECK-NEXT:]174 175 176#STRIP-BAR-NOT: Name: bar ({{.*}})177#REMAIN: Name: foobar178#REMAIN: Name: foobaz179