]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/elf/sectionGroups/sectiongroup-new-members.test
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / test / elf / sectionGroups / sectiongroup-new-members.test
1 # Checks that the linker picks the first group in the output file when the file
2 # have some members dont appear in the first group.
3 # 1a.s
4 # ------
5 #
6 #    .section .text,"axG",%progbits,foo_group,comdat
7 #    .weak foo
8 #foo:
9 #    .word 0
10 # 1b.s
11 # -----
12 #    .section .text,"axG",%progbits,foo_group,comdat
13 #    .global foo
14 #    .global bar
15 #foo:
16 #    .word 0
17 #bar:
18 #RUN: yaml2obj -format=elf -docnum 1 %s -o %t.group1a.o
19 #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.group1b.o
20 #RUN: lld -flavor gnu -target x86_64 %t.group1a.o %t.group1b.o \
21 #RUN: --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml
22 #RUN: lld -flavor gnu -target x86_64 %t.group1a.o %t.group1b.o \
23 #RUN: --noinhibit-exec -o %t2.out
24 #RUN: FileCheck %s -check-prefix=CHECKGROUP < %t2.out.yaml
25 #RUN: llvm-readobj -sections %t2.out | FileCheck %s -check-prefix=CHECKGROUPSECTIONS
26 #RUN: llvm-readobj -symbols  %t2.out | FileCheck %s -check-prefix=CHECKSYMBOLS
27 #CHECKGROUP:  - name:            foo
28 #CHECKGROUP:    scope:           global
29 #CHECKGROUP:    merge:           as-weak
30 #CHECKGROUP:    section-name:    .text
31 #CHECKGROUP:  - name:            foo_group
32 #CHECKGROUP:    scope:           global
33 #CHECKGROUP:    type:            group-comdat
34 #CHECKGROUP:    section-choice:  custom-required
35 #CHECKGROUP:    section-name:    .group
36 #CHECKGROUP:    permissions:     ---
37 #CHECKGROUP:    references:
38 #CHECKGROUP:      - kind:            group-child
39 #CHECKGROUP:        offset:          0
40 #CHECKGROUP:        target:          foo
41 #CHECKGROUPSECTIONS:  Section {
42 #CHECKGROUPSECTIONS:    Name: .text
43 #CHECKGROUPSECTIONS:    Type: SHT_PROGBITS
44 #CHECKGROUPSECTIONS:    Flags [ (0x6)
45 #CHECKGROUPSECTIONS:      SHF_ALLOC (0x2)
46 #CHECKGROUPSECTIONS:      SHF_EXECINSTR (0x4)
47 #CHECKGROUPSECTIONS:    ]
48 #CHECKGROUPSECTIONS:    Size: 2
49 #CHECKGROUPSECTIONS:    AddressAlignment: 1
50 #CHECKGROUPSECTIONS:  }
51 #CHECKSYMBOLS:   Name: foo
52 #CHECKSYMBOLS:   Type: Function
53 #CHECKSYMBOLS:   Section: .text
54 #CHECKSYMBOLS-NOT:   Name: bar
55 ---
56 FileHeader:
57   Class:           ELFCLASS64
58   Data:            ELFDATA2LSB
59   OSABI:           ELFOSABI_GNU
60   Type:            ET_REL
61   Machine:         EM_X86_64
62 Sections:
63   - Name:            .group
64     Type:            SHT_GROUP
65     Link:            .symtab
66     AddressAlign:    0x0000000000000004
67     Info:            foo_group
68     Members:
69       - SectionOrType:   GRP_COMDAT
70       - SectionOrType:   .text
71   - Name:            .data
72     Type:            SHT_PROGBITS
73     Flags:           [ SHF_WRITE, SHF_ALLOC ]
74     AddressAlign:    0x0000000000000004
75     Content:         ''
76   - Name:            .bss
77     Type:            SHT_NOBITS
78     Flags:           [ SHF_WRITE, SHF_ALLOC ]
79     AddressAlign:    0x0000000000000004
80     Content:         ''
81   - Name:            .text
82     Type:            SHT_PROGBITS
83     Flags:           [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
84     AddressAlign:    0x0000000000000001
85     Content:         '0000'
86 Symbols:
87   Local:
88     - Name:            foo_group
89       Section:         .group
90     - Name:            .text
91       Type:            STT_SECTION
92       Section:         .text
93     - Name:            .data
94       Type:            STT_SECTION
95       Section:         .data
96     - Name:            .bss
97       Type:            STT_SECTION
98       Section:         .bss
99   Weak:
100     - Name:            foo
101       Section:         .text
102 ...
103 ---
104 FileHeader:
105   Class:           ELFCLASS64
106   Data:            ELFDATA2LSB
107   OSABI:           ELFOSABI_GNU
108   Type:            ET_REL
109   Machine:         EM_X86_64
110 Sections:
111   - Name:            .group
112     Type:            SHT_GROUP
113     Link:            .symtab
114     AddressAlign:    0x0000000000000004
115     Info:            foo_group
116     Members:
117       - SectionOrType:   GRP_COMDAT
118       - SectionOrType:   .text
119   - Name:            .data
120     Type:            SHT_PROGBITS
121     Flags:           [ SHF_WRITE, SHF_ALLOC ]
122     AddressAlign:    0x0000000000000004
123     Content:         ''
124   - Name:            .bss
125     Type:            SHT_NOBITS
126     Flags:           [ SHF_WRITE, SHF_ALLOC ]
127     AddressAlign:    0x0000000000000004
128     Content:         ''
129   - Name:            .text
130     Type:            SHT_PROGBITS
131     Flags:           [ SHF_ALLOC, SHF_EXECINSTR, SHF_GROUP ]
132     AddressAlign:    0x0000000000000001
133     Content:         '0000'
134 Symbols:
135   Local:
136     - Name:            foo_group
137       Section:         .group
138     - Name:            .text
139       Type:            STT_SECTION
140       Section:         .text
141     - Name:            .data
142       Type:            STT_SECTION
143       Section:         .data
144     - Name:            .bss
145       Type:            STT_SECTION
146       Section:         .bss
147   Global:
148     - Name:            bar
149       Section:         .text
150       Value:           0x0000000000000002
151     - Name:            foo
152       Section:         .text
153 ...