xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/weaken.test (revision 30718f3aa62b81c2814564d2ca08888435202655)
1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objcopy --weaken-symbol Global -W Local -W Weak -W GnuUnique -W Missing %t %t2
3# RUN: llvm-readobj --symbols %t2 | FileCheck %s
4# RUN: llvm-objcopy --regex --weaken-symbol='[LGW].*' %t %t3
5# RUN: cmp %t2 %t3
6# RUN: echo "  Global  # comment" > %t-list.txt
7# RUN: echo "Local" >> %t-list.txt
8# RUN: echo "Weak" >> %t-list.txt
9# RUN: echo "GnuUnique" >> %t-list.txt
10# RUN: echo "Missing" >> %t-list.txt
11# RUN: echo " # comment" >> %t-list.txt
12# RUN: llvm-objcopy --weaken-symbols %t-list.txt %t %t4
13# RUN: cmp %t2 %t4
14# RUN: echo ".*al # Global + Local == .*al" > %t-list2.txt
15# RUN: echo "Weak # weak" >> %t-list2.txt
16# RUN: echo " Gnu.*" >> %t-list2.txt
17# RUN: llvm-objcopy --regex --weaken-symbols %t-list2.txt %t %t5
18# RUN: cmp %t2 %t5
19
20!ELF
21FileHeader:
22  Class:           ELFCLASS64
23  Data:            ELFDATA2LSB
24  Type:            ET_REL
25  Machine:         EM_X86_64
26Sections:
27  - Name:            .text
28    Type:            SHT_PROGBITS
29    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
30    Address:         0x1000
31    AddressAlign:    0x0000000000000010
32    Size:            64
33Symbols:
34  - Name:     Local
35    Type:     STT_FUNC
36    Section:  .text
37    Value:    0x1000
38    Size:     8
39  - Name:     Global
40    Type:     STT_FUNC
41    Size:     8
42    Section:  .text
43    Value:    0x1010
44    Binding:  STB_GLOBAL
45  - Name:     Weak
46    Type:     STT_FUNC
47    Size:     8
48    Section:  .text
49    Value:    0x1008
50    Binding:  STB_WEAK
51  - Name:     GnuUnique
52    Section:  .text
53    Binding:  STB_GNU_UNIQUE
54  - Name:     Unspecified
55    Section:  .text
56    Binding:  STB_GLOBAL
57
58#CHECK: Symbols [
59#CHECK-NEXT:  Symbol {
60#CHECK-NEXT:    Name:
61#CHECK-NEXT:    Value: 0x0
62#CHECK-NEXT:    Size: 0
63#CHECK-NEXT:    Binding: Local
64#CHECK-NEXT:    Type: None
65#CHECK-NEXT:    Other: 0
66#CHECK-NEXT:    Section: Undefined
67#CHECK-NEXT:  }
68#CHECK-NEXT:  Symbol {
69#CHECK-NEXT:    Name: Local
70#CHECK-NEXT:    Value: 0x1000
71#CHECK-NEXT:    Size: 8
72#CHECK-NEXT:    Binding: Local
73#CHECK-NEXT:    Type: Function
74#CHECK-NEXT:    Other: 0
75#CHECK-NEXT:    Section: .text
76#CHECK-NEXT:  }
77#CHECK-NEXT:  Symbol {
78#CHECK-NEXT:    Name: Global
79#CHECK-NEXT:    Value: 0x1010
80#CHECK-NEXT:    Size: 8
81#CHECK-NEXT:    Binding: Weak
82#CHECK-NEXT:    Type: Function
83#CHECK-NEXT:    Other: 0
84#CHECK-NEXT:    Section: .text
85#CHECK-NEXT:  }
86#CHECK-NEXT:  Symbol {
87#CHECK-NEXT:    Name: Weak
88#CHECK-NEXT:    Value: 0x1008
89#CHECK-NEXT:    Size: 8
90#CHECK-NEXT:    Binding: Weak
91#CHECK-NEXT:    Type: Function
92#CHECK-NEXT:    Other: 0
93#CHECK-NEXT:    Section: .text
94#CHECK-NEXT:  }
95#CHECK-NEXT:  Symbol {
96#CHECK-NEXT:    Name: GnuUnique
97#CHECK-NEXT:    Value: 0x0
98#CHECK-NEXT:    Size: 0
99#CHECK-NEXT:    Binding: Weak
100#CHECK-NEXT:    Type: None
101#CHECK-NEXT:    Other: 0
102#CHECK-NEXT:    Section: .text
103#CHECK-NEXT:  }
104#CHECK-NEXT:  Symbol {
105#CHECK-NEXT:    Name: Unspecified
106#CHECK-NEXT:    Value: 0x0
107#CHECK-NEXT:    Size: 0
108#CHECK-NEXT:    Binding: Global
109#CHECK-NEXT:    Type: None
110#CHECK-NEXT:    Other: 0
111#CHECK-NEXT:    Section: .text
112#CHECK-NEXT:  }
113#CHECK-NEXT:]
114