Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / COFF / baserel.test
blob4cf2e36ac107d9e7ce51b63722bb7e917ed38730
1 # RUN: yaml2obj %s -o %t.obj
3 # RUN: lld-link /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
4 # RUN: llvm-readobj --coff-basereloc %t.exe | FileCheck %s -check-prefix=BASEREL
6 # RUN: lld-link /out:%t.exe /entry:main /fixed %t.obj %p/Inputs/std64.lib
7 # RUN: llvm-readobj --coff-basereloc %t.exe | FileCheck %s -check-prefix=NOBASEREL
9 # BASEREL:      BaseReloc [
10 # BASEREL-NEXT: Entry {
11 # BASEREL-NEXT:   Type: DIR64
12 # BASEREL-NEXT:   Address: 0x1007
13 # BASEREL-NEXT: }
14 # BASEREL-NEXT: Entry {
15 # BASEREL-NEXT:   Type: DIR64
16 # BASEREL-NEXT:   Address: 0x100C
17 # BASEREL-NEXT: }
18 # BASEREL-NEXT: Entry {
19 # BASEREL-NEXT:   Type: DIR64
20 # BASEREL-NEXT:   Address: 0x101E
21 # BASEREL-NEXT: }
22 # BASEREL-NEXT: Entry {
23 # BASEREL-NEXT:   Type: ABSOLUTE
24 # BASEREL-NEXT:   Address: 0x1000
25 # BASEREL-NEXT: }
26 # BASEREL-NEXT: Entry {
27 # BASEREL-NEXT:   Type: DIR64
28 # BASEREL-NEXT:   Address: 0x4007
29 # BASEREL-NEXT: }
30 # BASEREL-NEXT: Entry {
31 # BASEREL-NEXT:   Type: DIR64
32 # BASEREL-NEXT:   Address: 0x400C
33 # BASEREL-NEXT: }
34 # BASEREL-NEXT: Entry {
35 # BASEREL-NEXT:   Type: DIR64
36 # BASEREL-NEXT:   Address: 0x401E
37 # BASEREL-NEXT: }
38 # BASEREL-NEXT: Entry {
39 # BASEREL-NEXT:   Type: ABSOLUTE
40 # BASEREL-NEXT:   Address: 0x4000
41 # BASEREL-NEXT: }
43 # NOBASEREL:      BaseReloc [
44 # NOBASEREL-NEXT: ]
46 # RUN: lld-link /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib
47 # RUN: llvm-readobj --file-headers --sections %t.exe | FileCheck %s \
48 # RUN:   --check-prefix=BASEREL-HEADER
50 # RUN: lld-link /out:%t.exe /entry:main /fixed %t.obj %p/Inputs/std64.lib
51 # RUN: llvm-readobj --file-headers %t.exe | FileCheck %s \
52 # RUN:   --check-prefix=NOBASEREL-HEADER
54 # BASEREL-HEADER-NOT: IMAGE_FILE_RELOCS_STRIPPED
56 # NOBASEREL-HEADER: IMAGE_FILE_RELOCS_STRIPPED
58 # BASEREL-HEADER:      BaseRelocationTableRVA: 0x5000
59 # BASEREL-HEADER:      BaseRelocationTableSize: 0x20
60 # BASEREL-HEADER:      Name: .reloc (2E 72 65 6C 6F 63 00 00)
61 # BASEREL-HEADER-NEXT: VirtualSize: 0x20
62 # BASEREL-HEADER-NEXT: VirtualAddress: 0x5000
63 # BASEREL-HEADER-NEXT: RawDataSize: 512
64 # BASEREL-HEADER-NEXT: PointerToRawData: 0xC00
65 # BASEREL-HEADER-NEXT: PointerToRelocations: 0x0
66 # BASEREL-HEADER-NEXT: PointerToLineNumbers: 0x0
67 # BASEREL-HEADER-NEXT: RelocationCount: 0
68 # BASEREL-HEADER-NEXT: LineNumberCount: 0
69 # BASEREL-HEADER-NEXT: Characteristics [ (0x42000040)
70 # BASEREL-HEADER-NEXT:   IMAGE_SCN_CNT_INITIALIZED_DATA (0x40)
71 # BASEREL-HEADER-NEXT:   IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
72 # BASEREL-HEADER-NEXT:   IMAGE_SCN_MEM_READ (0x40000000)
73 # BASEREL-HEADER-NEXT: ]
75 --- !COFF
76 header:
77   Machine:         IMAGE_FILE_MACHINE_AMD64
78   Characteristics: []
79 sections:
80   - Name:            .text
81     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
82     Alignment:       4096
83     SectionData:     B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000
84     Relocations:
85       - VirtualAddress:  0
86         SymbolName:      abs_symbol
87         Type:            IMAGE_REL_AMD64_ADDR64
88       - VirtualAddress:  7
89         SymbolName:      caption
90         Type:            IMAGE_REL_AMD64_ADDR64
91       - VirtualAddress:  12
92         SymbolName:      message
93         Type:            IMAGE_REL_AMD64_ADDR64
94       - VirtualAddress:  18
95         SymbolName:      MessageBoxA
96         Type:            IMAGE_REL_AMD64_REL32
97       - VirtualAddress:  24
98         SymbolName:      ExitProcess
99         Type:            IMAGE_REL_AMD64_REL32
100       - VirtualAddress:  30
101         SymbolName:      __ImageBase
102         Type:            IMAGE_REL_AMD64_ADDR64
103   - Name:            .text2
104     Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
105     Alignment:       4096
106     SectionData:     B800000000000000005068000000000000000068000000000000000050E8000000000000000050E8000000000000000050E80000000000000000
107     Relocations:
108       - VirtualAddress:  0
109         SymbolName:      abs_symbol
110         Type:            IMAGE_REL_AMD64_ADDR64
111       - VirtualAddress:  7
112         SymbolName:      caption
113         Type:            IMAGE_REL_AMD64_ADDR64
114       - VirtualAddress:  12
115         SymbolName:      message
116         Type:            IMAGE_REL_AMD64_ADDR64
117       - VirtualAddress:  18
118         SymbolName:      MessageBoxA
119         Type:            IMAGE_REL_AMD64_REL32
120       - VirtualAddress:  24
121         SymbolName:      ExitProcess
122         Type:            IMAGE_REL_AMD64_REL32
123       - VirtualAddress:  30
124         SymbolName:      __ImageBase
125         Type:            IMAGE_REL_AMD64_ADDR64
126   - Name:            .data
127     Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
128     Alignment:       4
129     SectionData:     48656C6C6F0048656C6C6F20576F726C6400
130 symbols:
131   - Name:            "@comp.id"
132     Value:           10394907
133     SectionNumber:   65535
134     SimpleType:      IMAGE_SYM_TYPE_NULL
135     ComplexType:     IMAGE_SYM_DTYPE_NULL
136     StorageClass:    IMAGE_SYM_CLASS_STATIC
137   - Name:            .text
138     Value:           0
139     SectionNumber:   1
140     SimpleType:      IMAGE_SYM_TYPE_NULL
141     ComplexType:     IMAGE_SYM_DTYPE_NULL
142     StorageClass:    IMAGE_SYM_CLASS_STATIC
143     SectionDefinition:
144       Length:          28
145       NumberOfRelocations: 6
146       NumberOfLinenumbers: 0
147       CheckSum:        0
148       Number:          0
149   - Name:            .text2
150     Value:           0
151     SectionNumber:   1
152     SimpleType:      IMAGE_SYM_TYPE_NULL
153     ComplexType:     IMAGE_SYM_DTYPE_NULL
154     StorageClass:    IMAGE_SYM_CLASS_STATIC
155     SectionDefinition:
156       Length:          28
157       NumberOfRelocations: 6
158       NumberOfLinenumbers: 0
159       CheckSum:        0
160       Number:          0
161   - Name:            .data
162     Value:           0
163     SectionNumber:   3
164     SimpleType:      IMAGE_SYM_TYPE_NULL
165     ComplexType:     IMAGE_SYM_DTYPE_NULL
166     StorageClass:    IMAGE_SYM_CLASS_STATIC
167     SectionDefinition:
168       Length:          18
169       NumberOfRelocations: 0
170       NumberOfLinenumbers: 0
171       CheckSum:        0
172       Number:          0
173   - Name:            MessageBoxA
174     Value:           0
175     SectionNumber:   0
176     SimpleType:      IMAGE_SYM_TYPE_NULL
177     ComplexType:     IMAGE_SYM_DTYPE_NULL
178     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
179   - Name:            ExitProcess
180     Value:           0
181     SectionNumber:   0
182     SimpleType:      IMAGE_SYM_TYPE_NULL
183     ComplexType:     IMAGE_SYM_DTYPE_NULL
184     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
185   - Name:            message
186     Value:           6
187     SectionNumber:   2
188     SimpleType:      IMAGE_SYM_TYPE_NULL
189     ComplexType:     IMAGE_SYM_DTYPE_NULL
190     StorageClass:    IMAGE_SYM_CLASS_STATIC
191   - Name:            main
192     Value:           0
193     SectionNumber:   1
194     SimpleType:      IMAGE_SYM_TYPE_NULL
195     ComplexType:     IMAGE_SYM_DTYPE_NULL
196     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
197   - Name:            caption
198     Value:           0
199     SectionNumber:   2
200     SimpleType:      IMAGE_SYM_TYPE_NULL
201     ComplexType:     IMAGE_SYM_DTYPE_NULL
202     StorageClass:    IMAGE_SYM_CLASS_STATIC
203   - Name:            abs_symbol
204     Value:           0xDEADBEEF
205     SectionNumber:   -1
206     SimpleType:      IMAGE_SYM_TYPE_NULL
207     ComplexType:     IMAGE_SYM_DTYPE_NULL
208     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
209   - Name:            __ImageBase
210     Value:           0
211     SectionNumber:   0
212     SimpleType:      IMAGE_SYM_TYPE_NULL
213     ComplexType:     IMAGE_SYM_DTYPE_NULL
214     StorageClass:    IMAGE_SYM_CLASS_EXTERNAL