xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/strip-symbol.test (revision 1562e4552cd1b3d2eadd956c966f8a60e928b8ca)
1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objcopy --strip-symbol baz -N bar %t %t2
3# RUN: llvm-readobj --symbols --sections %t2 | FileCheck %s
4# RUN: llvm-strip --strip-symbol baz -N bar %t -o %t3
5# RUN: cmp %t2 %t3
6# RUN: llvm-objcopy --regex --strip-symbol '^b.*' -N bar %t %t4
7# RUN: cmp %t2 %t4
8# RUN: llvm-strip --regex --strip-symbol '^b.*' -N bar %t -o %t5
9# RUN: cmp %t3 %t5
10# RUN: echo " bar # bar" > %t-list.txt
11# RUN: echo " baz # baz" >> %t-list.txt
12# RUN: echo " # no symbol" >> %t-list.txt
13# RUN: llvm-objcopy --strip-symbols %t-list.txt %t %t6
14# RUN: cmp %t3 %t6
15# RUN: echo "b.* # bar & baz" > %t-list2.txt
16# RUN: llvm-objcopy --regex --strip-symbols %t-list2.txt %t %t7
17# RUN: cmp %t3 %t7
18
19!ELF
20FileHeader:
21  Class:           ELFCLASS64
22  Data:            ELFDATA2LSB
23  Type:            ET_REL
24  Machine:         EM_X86_64
25Sections:
26  - Name:            .text
27    Type:            SHT_PROGBITS
28    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
29    Address:         0x1000
30    AddressAlign:    0x0000000000000010
31    Size:            64
32Symbols:
33  - Name:     foo
34    Type:     STT_FUNC
35    Section:  .text
36    Value:    0x1000
37    Size:     8
38  - Name:     bar
39    Type:     STT_FUNC
40    Size:     8
41    Section:  .text
42    Value:    0x1008
43    Binding:  STB_WEAK
44  - Name:     baz
45    Type:     STT_FUNC
46    Size:     8
47    Section:  .text
48    Value:    0x1010
49    Binding:  STB_GLOBAL
50
51#CHECK: Symbols [
52#CHECK-NEXT:  Symbol {
53#CHECK-NEXT:    Name:
54#CHECK-NEXT:    Value: 0x0
55#CHECK-NEXT:    Size: 0
56#CHECK-NEXT:    Binding: Local
57#CHECK-NEXT:    Type: None
58#CHECK-NEXT:    Other: 0
59#CHECK-NEXT:    Section: Undefined
60#CHECK-NEXT:  }
61#CHECK-NEXT:  Symbol {
62#CHECK-NEXT:    Name: foo
63#CHECK-NEXT:    Value: 0x1000
64#CHECK-NEXT:    Size: 8
65#CHECK-NEXT:    Binding: Local
66#CHECK-NEXT:    Type: Function
67#CHECK-NEXT:    Other: 0
68#CHECK-NEXT:    Section: .text
69#CHECK-NEXT:  }
70#CHECK-NEXT:]
71