]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/elf/sectionGroups/sectiongroup-with-globalsymbols.test
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / test / elf / sectionGroups / sectiongroup-with-globalsymbols.test
1 # This tests that comdat weak symbol can be overridden by a global symbol.
2 # comdat1.s
3 #------------------------
4 #       .weak g1
5 #        .section .foo,"axG",@progbits,g1,comdat
6 #g1:
7 #        nop
8 #        .global g2
9 #g2:
10 #        nop
11 #!
12 #
13 #comdat2.s << \!
14 #-----------------
15 #       .global g1
16 #        .section .foo,"axG",@progbits,g1,comdat
17 #g1:
18 #        nop
19 #        .global g2
20 #g2:
21 #        nop
22 #
23 #cat > g1.c << \!
24 #int g1() {
25 #  return 0;
26 #}
27 #
28 #RUN: yaml2obj -format=elf -docnum 1 %s -o %t.comdat1.o
29 #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.comdat2.o
30 #RUN: yaml2obj -format=elf -docnum 3 %s -o %t.g1.o
31 #RUN: lld -flavor gnu -target x86_64 %t.comdat1.o %t.comdat2.o \
32 #RUN: %t.g1.o --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml
33 #RUN: lld -flavor gnu -target x86_64 %t.comdat1.o %t.comdat2.o \
34 #RUN: %t.g1.o --noinhibit-exec -o %t2.out
35 #RUN: FileCheck %s -check-prefix=CHECKGROUP < %t2.out.yaml
36 #RUN: llvm-readobj -sections %t2.out | FileCheck %s -check-prefix=CHECKGROUPSECTIONS
37 #RUN: llvm-readobj -symbols %t2.out | FileCheck %s -check-prefix=CHECKSYMBOLS
38 #CHECKGROUP:  - name:            g2
39 #CHECKGROUP:    content:         [ 90 ]
40 #CHECKGROUP:    section-choice:  custom-required
41 #CHECKGROUP:    section-name:    .foo
42 #CHECKGROUP:  - name:            g1
43 #CHECKGROUP:    scope:           global
44 #CHECKGROUP:    content:         [ 55, 48, 89, E5, 31, C0, 5D, C3 ]
45 #CHECKGROUP:    alignment:       2^4
46 #CHECKGROUP:    section-name:    .text
47 #CHECKGROUPSECTIONS:    Name: .text
48 #CHECKGROUPSECTIONS:    Type: SHT_PROGBITS
49 #CHECKGROUPSECTIONS:    Flags [
50 #CHECKGROUPSECTIONS:      SHF_ALLOC
51 #CHECKGROUPSECTIONS:      SHF_EXECINSTR
52 #CHECKGROUPSECTIONS:    ]
53 #CHECKGROUPSECTIONS:    Size: 8
54 #CHECKGROUPSECTIONS:    Name: .foo
55 #CHECKGROUPSECTIONS:    Type: SHT_PROGBITS
56 #CHECKGROUPSECTIONS:    Flags [
57 #CHECKGROUPSECTIONS:      SHF_ALLOC
58 #CHECKGROUPSECTIONS:      SHF_EXECINSTR
59 #CHECKGROUPSECTIONS:    ]
60 #CHECKGROUPSECTIONS:    Size: 2
61 #CHECKSYMBOLS:    Name: g2
62 #CHECKSYMBOLS:    Section: .foo
63 #CHECKSYMBOLS:    Name: g1
64 #CHECKSYMBOLS:    Section: .text
65 ---
66 FileHeader:
67   Class:           ELFCLASS64
68   Data:            ELFDATA2LSB
69   OSABI:           ELFOSABI_GNU
70   Type:            ET_REL
71   Machine:         EM_X86_64
72 Sections:
73   - Name:            .group
74     Type:            SHT_GROUP
75     Link:            .symtab
76     AddressAlign:    0x0000000000000004
77     Info:            g1
78     Members:
79       - SectionOrType:   GRP_COMDAT
80       - SectionOrType:   .foo
81   - Name:            .text
82     Type:            SHT_PROGBITS
83     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
84     AddressAlign:    0x0000000000000004
85     Content:         ''
86   - Name:            .data
87     Type:            SHT_PROGBITS
88     Flags:           [ SHF_WRITE, SHF_ALLOC ]
89     AddressAlign:    0x0000000000000004
90     Content:         ''
91   - Name:            .bss
92     Type:            SHT_NOBITS
93     Flags:           [ SHF_WRITE, SHF_ALLOC ]
94     AddressAlign:    0x0000000000000004
95     Content:         ''
96   - Name:            .foo
97     Type:            SHT_PROGBITS
98     Flags:           [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
99     AddressAlign:    0x0000000000000001
100     Content:         '9090'
101 Symbols:
102   Local:
103     - Name:            .text
104       Type:            STT_SECTION
105       Section:         .text
106     - Name:            .data
107       Type:            STT_SECTION
108       Section:         .data
109     - Name:            .bss
110       Type:            STT_SECTION
111       Section:         .bss
112     - Name:            .foo
113       Type:            STT_SECTION
114       Section:         .foo
115   Global:
116     - Name:            g2
117       Section:         .foo
118       Value:           0x0000000000000001
119   Weak:
120     - Name:            g1
121       Section:         .foo
122 ...
123 ---
124 FileHeader:
125   Class:           ELFCLASS64
126   Data:            ELFDATA2LSB
127   OSABI:           ELFOSABI_GNU
128   Type:            ET_REL
129   Machine:         EM_X86_64
130 Sections:
131   - Name:            .group
132     Type:            SHT_GROUP
133     Link:            .symtab
134     AddressAlign:    0x0000000000000004
135     Info:            g1
136     Members:
137       - SectionOrType:   GRP_COMDAT
138       - SectionOrType:   .foo
139   - Name:            .text
140     Type:            SHT_PROGBITS
141     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
142     AddressAlign:    0x0000000000000004
143     Content:         ''
144   - Name:            .data
145     Type:            SHT_PROGBITS
146     Flags:           [ SHF_WRITE, SHF_ALLOC ]
147     AddressAlign:    0x0000000000000004
148     Content:         ''
149   - Name:            .bss
150     Type:            SHT_NOBITS
151     Flags:           [ SHF_WRITE, SHF_ALLOC ]
152     AddressAlign:    0x0000000000000004
153     Content:         ''
154   - Name:            .foo
155     Type:            SHT_PROGBITS
156     Flags:           [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
157     AddressAlign:    0x0000000000000001
158     Content:         '9090'
159 Symbols:
160   Local:
161     - Name:            .text
162       Type:            STT_SECTION
163       Section:         .text
164     - Name:            .data
165       Type:            STT_SECTION
166       Section:         .data
167     - Name:            .bss
168       Type:            STT_SECTION
169       Section:         .bss
170     - Name:            .foo
171       Type:            STT_SECTION
172       Section:         .foo
173   Global:
174     - Name:            g1
175       Section:         .foo
176     - Name:            g2
177       Section:         .foo
178       Value:           0x0000000000000001
179 ...
180 ---
181 FileHeader:
182   Class:           ELFCLASS64
183   Data:            ELFDATA2LSB
184   OSABI:           ELFOSABI_GNU
185   Type:            ET_REL
186   Machine:         EM_X86_64
187 Sections:
188   - Name:            .text
189     Type:            SHT_PROGBITS
190     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
191     AddressAlign:    0x0000000000000010
192     Content:         554889E531C05DC3
193   - Name:            .data
194     Type:            SHT_PROGBITS
195     Flags:           [ SHF_WRITE, SHF_ALLOC ]
196     AddressAlign:    0x0000000000000004
197     Content:         ''
198   - Name:            .bss
199     Type:            SHT_NOBITS
200     Flags:           [ SHF_WRITE, SHF_ALLOC ]
201     AddressAlign:    0x0000000000000004
202     Content:         ''
203   - Name:            .comment
204     Type:            SHT_PROGBITS
205     Flags:           [ SHF_MERGE, SHF_STRINGS ]
206     AddressAlign:    0x0000000000000001
207     Content:         00636C616E672076657273696F6E20332E372E3020287472756E6B203232393535372920286C6C766D2F7472756E6B203232393536332900
208   - Name:            .note.GNU-stack
209     Type:            SHT_PROGBITS
210     AddressAlign:    0x0000000000000001
211     Content:         ''
212   - Name:            .eh_frame
213     Type:            SHT_PROGBITS
214     Flags:           [ SHF_ALLOC ]
215     AddressAlign:    0x0000000000000008
216     Content:         1400000000000000037A5200017810011B0C0708900100001C0000001C000000000000000800000000410E108602430D0600000000000000
217   - Name:            .rela.eh_frame
218     Type:            SHT_RELA
219     Link:            .symtab
220     AddressAlign:    0x0000000000000008
221     Info:            .eh_frame
222     Relocations:
223       - Offset:          0x0000000000000020
224         Symbol:          .text
225         Type:            R_X86_64_PC32
226 Symbols:
227   Local:
228     - Name:            g1.c
229       Type:            STT_FILE
230     - Name:            .text
231       Type:            STT_SECTION
232       Section:         .text
233     - Name:            .data
234       Type:            STT_SECTION
235       Section:         .data
236     - Name:            .bss
237       Type:            STT_SECTION
238       Section:         .bss
239     - Name:            .comment
240       Type:            STT_SECTION
241       Section:         .comment
242     - Name:            .note.GNU-stack
243       Type:            STT_SECTION
244       Section:         .note.GNU-stack
245     - Name:            .eh_frame
246       Type:            STT_SECTION
247       Section:         .eh_frame
248   Global:
249     - Name:            g1
250       Type:            STT_FUNC
251       Section:         .text
252       Size:            0x0000000000000008
253 ...