@@ -3,17 +3,17 @@ RUN: split-file %s %t.dir && cd %t.dir
3
3
4
4
RUN: llvm-mc -filetype=obj -triple=arm64-windows arm64-func-sym.s -o arm64-func-sym.obj
5
5
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym.s -o arm64ec-func-sym.obj
6
+ RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym2.s -o arm64ec-func-sym2.obj
6
7
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec.s -o data-sec.obj
8
+ RUN: llvm-mc -filetype=obj -triple=arm64ec-windows empty-sec.s -o arm64ec-empty-sec.obj
7
9
RUN: llvm-mc -filetype=obj -triple=x86_64-windows x86_64-func-sym.s -o x86_64-func-sym.obj
8
- RUN: llvm-mc -filetype=obj -triple=arm64ec-windows codemap.s -o codemap.obj
9
- RUN: llvm-mc -filetype=obj -triple=arm64ec-windows codemap2.s -o codemap2.obj
10
- RUN: llvm-mc -filetype=obj -triple=arm64ec-windows codemap3.s -o codemap3.obj
10
+ RUN: llvm-mc -filetype=obj -triple=x86_64-windows empty-sec.s -o x86_64-empty-sec.obj
11
11
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
12
12
13
13
Link ARM64EC DLL and verify that the code is arranged as expected.
14
14
15
15
RUN: lld-link -out:test.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj \
16
- RUN: codemap.obj loadconfig-arm64ec.obj -dll -noentry
16
+ RUN: loadconfig-arm64ec.obj -dll -noentry
17
17
18
18
RUN: llvm-readobj --coff-load-config test.dll | FileCheck -check-prefix=CODEMAP %s
19
19
CODEMAP: CodeMap [
@@ -45,12 +45,18 @@ DISASM-NEXT: 180006005: c3 retq
45
45
Order of arguments doesn't matter in this case, chunks are sorted by target type anyway.
46
46
47
47
RUN: lld-link -out:test2.dll -machine:arm64ec x86_64-func-sym.obj arm64ec-func-sym.obj \
48
- RUN: codemap.obj loadconfig-arm64ec.obj -dll -noentry
48
+ RUN: loadconfig-arm64ec.obj -dll -noentry
49
49
RUN: llvm-readobj --coff-load-config test2.dll | FileCheck -check-prefix=CODEMAP %s
50
50
RUN: llvm-objdump -d test2.dll | FileCheck -check-prefix=DISASM %s
51
51
52
52
RUN: lld-link -out:testx.dll -machine:arm64x arm64-func-sym.obj arm64ec-func-sym.obj \
53
- RUN: x86_64-func-sym.obj codemap2.obj loadconfig-arm64ec.obj -dll -noentry
53
+ RUN: x86_64-func-sym.obj loadconfig-arm64ec.obj -dll -noentry
54
+
55
+ Adding empty chunks does not affect code map ranges.
56
+
57
+ RUN: lld-link -out:test3.dll -machine:arm64ec x86_64-empty-sec.obj arm64ec-empty-sec.obj \
58
+ RUN: arm64ec-func-sym.obj x86_64-func-sym.obj loadconfig-arm64ec.obj -dll -noentry
59
+ RUN: llvm-readobj --coff-load-config test3.dll | FileCheck -check-prefix=CODEMAP %s
54
60
55
61
Do the same with ARM64X target.
56
62
@@ -88,7 +94,7 @@ DISASMX-NEXT: 180007005: c3 retq
88
94
Test merged sections.
89
95
90
96
RUN: lld-link -out:testm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj \
91
- RUN: codemap3.obj loadconfig-arm64ec.obj -dll -noentry -merge:test=.text
97
+ RUN: loadconfig-arm64ec.obj -dll -noentry -merge:test=.text
92
98
93
99
RUN: llvm-readobj --coff-load-config testm.dll | FileCheck -check-prefix=CODEMAPM %s
94
100
CODEMAPM: CodeMap [
@@ -113,7 +119,7 @@ DISASMM-NEXT: 18000200d: c3 retq
113
119
114
120
Merging data sections into code sections causes data to be separated from the code when sorting chunks.
115
121
116
- RUN: lld-link -out:testdm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj codemap.obj \
122
+ RUN: lld-link -out:testdm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj \
117
123
RUN: data-sec.obj loadconfig-arm64ec.obj -dll -noentry -merge:.testdata=.text -merge:.rdata=test
118
124
119
125
RUN: llvm-readobj --coff-load-config testdm.dll | FileCheck -check-prefix=CODEMAPDM %s
@@ -145,6 +151,59 @@ DISASMDM-NEXT: ...
145
151
DISASMDM-NEXT: 180007000: b8 06 00 00 00 movl $0x6, %eax
146
152
DISASMDM-NEXT: 180007005: c3 retq
147
153
154
+ Merging a code section into data section produces a valid code map.
155
+
156
+ RUN: lld-link -out:testcm.dll -machine:arm64ec x86_64-func-sym.obj data-sec.obj \
157
+ RUN: loadconfig-arm64ec.obj -dll -noentry -merge:test=.testdata -merge:.text=.testdata
158
+
159
+ RUN: llvm-readobj --coff-load-config testcm.dll | FileCheck -check-prefix=CODEMAPCM %s
160
+ CODEMAPCM: CodeMap [
161
+ CODEMAPCM-NEXT: 0x3008 - 0x3016 X64
162
+ CODEMAPCM-NEXT: ]
163
+
164
+ RUN: llvm-objdump -d testcm.dll | FileCheck -check-prefix=DISASMCM %s
165
+ DISASMCM: Disassembly of section .testdat:
166
+ DISASMCM-EMPTY:
167
+ DISASMCM-NEXT: 0000000180003000 <.testdat>:
168
+ DISASMCM-NEXT: 180003000: 00000001 udf #0x1
169
+ DISASMCM-NEXT: 180003004: 00000000 udf #0x0
170
+ DISASMCM-NEXT: 180003008: b8 03 00 00 00 movl $0x3, %eax
171
+ DISASMCM-NEXT: 18000300d: c3 retq
172
+ DISASMCM-NEXT: 18000300e: 00 00 addb %al, (%rax)
173
+ DISASMCM-NEXT: 180003010: b8 06 00 00 00 movl $0x6, %eax
174
+ DISASMCM-NEXT: 180003015: c3
175
+
176
+ Test code map range entry spanning over multiple sections.
177
+
178
+ RUN: lld-link -out:testms.dll -machine:arm64ec arm64ec-func-sym.obj arm64ec-func-sym2.obj \
179
+ RUN: loadconfig-arm64ec.obj -dll -noentry
180
+
181
+ RUN: llvm-readobj --coff-load-config testms.dll | FileCheck -check-prefix=CODEMAPMS %s
182
+ CODEMAPMS: CodeMap [
183
+ CODEMAPMS-NEXT: 0x1000 - 0x1008 ARM64EC
184
+ CODEMAPMS-NEXT: 0x4000 - 0x5008 ARM64EC
185
+ CODEMAPMS-NEXT: ]
186
+
187
+ RUN: llvm-objdump -d testms.dll | FileCheck -check-prefix=DISASMMS %s
188
+ DISASMMS: Disassembly of section .text:
189
+ DISASMMS-EMPTY:
190
+ DISASMMS-NEXT: 0000000180001000 <.text>:
191
+ DISASMMS-NEXT: 180001000: 52800040 mov w0, #0x2 // =2
192
+ DISASMMS-NEXT: 180001004: d65f03c0 ret
193
+ DISASMMS-EMPTY:
194
+ DISASMMS-NEXT: Disassembly of section test:
195
+ DISASMMS-EMPTY:
196
+ DISASMMS-NEXT: 0000000180004000 <test>:
197
+ DISASMMS-NEXT: 180004000: 528000a0 mov w0, #0x5 // =5
198
+ DISASMMS-NEXT: 180004004: d65f03c0 ret
199
+ DISASMMS-EMPTY:
200
+ DISASMMS-NEXT: Disassembly of section test2:
201
+ DISASMMS-EMPTY:
202
+ DISASMMS-NEXT: 0000000180005000 <test2>:
203
+ DISASMMS-NEXT: 180005000: 528000a0 mov w0, #0x5 // =5
204
+ DISASMMS-NEXT: 180005004: d65f03c0 ret
205
+
206
+
148
207
#--- arm64-func-sym.s
149
208
.text
150
209
.globl arm64_func_sym
@@ -168,6 +227,14 @@ arm64ec_func_sym2:
168
227
mov w0, #5
169
228
ret
170
229
230
+ #--- arm64ec-func-sym2.s
231
+ .section test2, "xr"
232
+ .globl arm64ec_func_sym3
233
+ .p2align 2, 0x0
234
+ arm64ec_func_sym3:
235
+ mov w0, #5
236
+ ret
237
+
171
238
#--- x86_64-func-sym.s
172
239
.text
173
240
.globl x86_64_func_sym
@@ -187,48 +254,7 @@ x86_64_func_sym2:
187
254
.section .testdata, "rd"
188
255
.xword 1
189
256
190
- #--- codemap.s
191
- .section .rdata,"dr"
192
- .globl code_map
193
- code_map:
194
- .rva arm64ec_func_sym + 1
195
- .word 8
196
- .rva x86_64_func_sym + 2
197
- .word 6
198
- .rva arm64ec_func_sym2 + 1
199
- .word 8
200
- .rva x86_64_func_sym2 + 2
201
- .word 6
202
-
203
- .globl code_map_count
204
- code_map_count = 4
205
-
206
- #--- codemap2.s
207
- .section .rdata,"dr"
208
- .globl code_map
209
- code_map:
210
- .rva arm64_func_sym
211
- .word 8
212
- .rva arm64ec_func_sym + 1
213
- .word 8
214
- .rva x86_64_func_sym + 2
215
- .word 6
216
- .rva arm64ec_func_sym2 + 1
217
- .word 8
218
- .rva x86_64_func_sym2 + 2
219
- .word 6
220
-
221
- .globl code_map_count
222
- code_map_count = 5
223
-
224
- #--- codemap3.s
225
- .section .rdata,"dr"
226
- .globl code_map
227
- code_map:
228
- .rva arm64ec_func_sym + 1
229
- .word 16
230
- .rva x86_64_func_sym + 2
231
- .word 14
232
-
233
- .globl code_map_count
234
- code_map_count = 2
257
+ #--- empty-sec.s
258
+ .section .empty1, "xr"
259
+ .section .empty2, "xr"
260
+ .section .empty3, "xr"
0 commit comments