]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/elf/gnulinkonce/gnulinkonce.test
Vendor import of lld trunk r233088:
[FreeBSD/FreeBSD.git] / test / elf / gnulinkonce / gnulinkonce.test
1 # Tests that the linker is able to read .gnu.linkonce sections and link them
2 # appropriately. The testcase has been created by using the following source
3 # code
4 # linkonce1a.s
5 # ------------
6 #        .section .gnu.linkonce.d.dummy,"aw"
7 #bar:
8 #        .long    0
9 # linkonce1b.s
10 # ------------
11 #    .globl main
12 #    .globl start
13 #    .globl _start
14 #    .globl __start
15 #    .text
16 #main:
17 #start:
18 #_start:
19 #__start:
20 #    .long    0
21 #
22 #        .section .gnu.linkonce.d.dummy,"aw"
23 #foo:
24 #        .long    0
25 #RUN: yaml2obj -format=elf -docnum 1 %s -o %t.linkonce1a.o
26 #RUN: yaml2obj -format=elf -docnum 2 %s -o %t.linkonce1b.o
27 #RUN: lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \
28 #RUN: --noinhibit-exec --output-filetype=yaml -o %t2.out.yaml
29 #RUN: lld -flavor gnu -target x86_64 %t.linkonce1a.o %t.linkonce1b.o \
30 #RUN: --noinhibit-exec -o %t2.out
31 #RUN: FileCheck %s -check-prefix=CHECKGNULINKONCE < %t2.out.yaml
32 #RUN: llvm-readobj -sections %t2.out | FileCheck %s -check-prefix=CHECKGNULINKONCESECTIONS
33 #CHECKGNULINKONCE: - name:            .gnu.linkonce.d.dummy
34 #CHECKGNULINKONCE:   scope:           global
35 #CHECKGNULINKONCE:   type:            gnu-linkonce
36 #CHECKGNULINKONCE:   section-choice:  custom-required
37 #CHECKGNULINKONCE:   section-name:    .gnu.linkonce.d.dummy
38 #CHECKGNULINKONCE:   permissions:     rw-
39 #CHECKGNULINKONCE:   references:
40 #CHECKGNULINKONCE:     - kind:            group-child
41 #CHECKGNULINKONCE:       offset:          0
42 #CHECKGNULINKONCE:       target:          bar
43 #CHECKGNULINKONCE:     - kind:            group-child
44 #CHECKGNULINKONCE:       offset:          0
45 #CHECKGNULINKONCESECTIONS:   Section {
46 #CHECKGNULINKONCESECTIONS:     Name: .gnu.linkonce.d.dummy
47 #CHECKGNULINKONCESECTIONS:     Type: SHT_PROGBITS
48 #CHECKGNULINKONCESECTIONS:     Flags [ (0x3)
49 #CHECKGNULINKONCESECTIONS:       SHF_ALLOC (0x2)
50 #CHECKGNULINKONCESECTIONS:       SHF_WRITE (0x1)
51 #CHECKGNULINKONCESECTIONS:     ]
52 #CHECKGNULINKONCESECTIONS:     Size: 4
53 #CHECKGNULINKONCESECTIONS:   }
54 ---
55 FileHeader:
56   Class:           ELFCLASS64
57   Data:            ELFDATA2LSB
58   OSABI:           ELFOSABI_GNU
59   Type:            ET_REL
60   Machine:         EM_X86_64
61 Sections:
62   - Name:            .text
63     Type:            SHT_PROGBITS
64     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
65     AddressAlign:    0x0000000000000004
66     Content:         ''
67   - Name:            .data
68     Type:            SHT_PROGBITS
69     Flags:           [ SHF_WRITE, SHF_ALLOC ]
70     AddressAlign:    0x0000000000000004
71     Content:         ''
72   - Name:            .bss
73     Type:            SHT_NOBITS
74     Flags:           [ SHF_WRITE, SHF_ALLOC ]
75     AddressAlign:    0x0000000000000004
76     Content:         ''
77   - Name:            .gnu.linkonce.d.dummy
78     Type:            SHT_PROGBITS
79     Flags:           [ SHF_WRITE, SHF_ALLOC ]
80     AddressAlign:    0x0000000000000001
81     Content:         '00000000'
82 Symbols:
83   Local:
84     - Name:            bar
85       Section:         .gnu.linkonce.d.dummy
86     - Name:            .text
87       Type:            STT_SECTION
88       Section:         .text
89     - Name:            .data
90       Type:            STT_SECTION
91       Section:         .data
92     - Name:            .bss
93       Type:            STT_SECTION
94       Section:         .bss
95     - Name:            .gnu.linkonce.d.dummy
96       Type:            STT_SECTION
97       Section:         .gnu.linkonce.d.dummy
98 ...
99 ---
100 FileHeader:
101   Class:           ELFCLASS64
102   Data:            ELFDATA2LSB
103   Type:            ET_REL
104   Machine:         EM_X86_64
105 Sections:
106   - Name:            .text
107     Type:            SHT_PROGBITS
108     Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
109     AddressAlign:    0x0000000000000004
110     Content:         '00000000'
111   - Name:            .data
112     Type:            SHT_PROGBITS
113     Flags:           [ SHF_WRITE, SHF_ALLOC ]
114     AddressAlign:    0x0000000000000004
115     Content:         ''
116   - Name:            .bss
117     Type:            SHT_NOBITS
118     Flags:           [ SHF_WRITE, SHF_ALLOC ]
119     AddressAlign:    0x0000000000000004
120     Content:         ''
121   - Name:            .gnu.linkonce.d.dummy
122     Type:            SHT_PROGBITS
123     Flags:           [ SHF_WRITE, SHF_ALLOC ]
124     AddressAlign:    0x0000000000000001
125     Content:         '00000000'
126 Symbols:
127   Local:
128     - Name:            .text
129       Type:            STT_SECTION
130       Section:         .text
131     - Name:            .data
132       Type:            STT_SECTION
133       Section:         .data
134     - Name:            .bss
135       Type:            STT_SECTION
136       Section:         .bss
137     - Name:            .gnu.linkonce.d.dummy
138       Type:            STT_SECTION
139       Section:         .gnu.linkonce.d.dummy
140     - Name:            foo
141       Section:         .gnu.linkonce.d.dummy
142   Global:
143     - Name:            main
144       Section:         .text
145     - Name:            start
146       Section:         .text
147     - Name:            _start
148       Section:         .text
149     - Name:            __start
150       Section:         .text
151 ...