2 RUN: split-file %s %t.dir && cd %t.dir
4 RUN: llvm-mc -filetype=obj -triple=arm64-windows arm64-func-sym.s -o arm64-func-sym.obj
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 data-sec.s -o data-sec.obj
7 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
11 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
13 Link ARM64EC DLL and verify that the code is arranged as expected.
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
18 RUN: llvm-readobj --coff-load-config test.dll | FileCheck -check-prefix=CODEMAP %s
20 CODEMAP-NEXT: 0x1000 - 0x1008 ARM64EC
21 CODEMAP-NEXT: 0x2000 - 0x2006 X64
22 CODEMAP-NEXT: 0x5000 - 0x5008 ARM64EC
23 CODEMAP-NEXT: 0x6000 - 0x6006 X64
26 RUN: llvm-objdump -d test.dll | FileCheck -check-prefix=DISASM %s
27 DISASM: Disassembly of section .text:
29 DISASM-NEXT: 0000000180001000 <.text>:
30 DISASM-NEXT: 180001000: 52800040 mov w0, #0x2
31 DISASM-NEXT: 180001004: d65f03c0 ret
33 DISASM-NEXT: 180002000: b8 03 00 00 00 movl $0x3, %eax
34 DISASM-NEXT: 180002005: c3 retq
36 DISASM-NEXT: Disassembly of section test:
38 DISASM-NEXT: 0000000180005000 <test>:
39 DISASM-NEXT: 180005000: 528000a0 mov w0, #0x5
40 DISASM-NEXT: 180005004: d65f03c0 ret
42 DISASM-NEXT: 180006000: b8 06 00 00 00 movl $0x6, %eax
43 DISASM-NEXT: 180006005: c3 retq
45 Order of arguments doesn't matter in this case, chunks are sorted by target type anyway.
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
49 RUN: llvm-readobj --coff-load-config test2.dll | FileCheck -check-prefix=CODEMAP %s
50 RUN: llvm-objdump -d test2.dll | FileCheck -check-prefix=DISASM %s
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
55 Do the same with ARM64X target.
57 RUN: llvm-readobj --coff-load-config testx.dll | FileCheck -check-prefix=CODEMAPX %s
59 CODEMAPX-NEXT: 0x1000 - 0x1008 ARM64
60 CODEMAPX-NEXT: 0x2000 - 0x2008 ARM64EC
61 CODEMAPX-NEXT: 0x3000 - 0x3006 X64
62 CODEMAPX-NEXT: 0x6000 - 0x6008 ARM64EC
63 CODEMAPX-NEXT: 0x7000 - 0x7006 X64
66 RUN: llvm-objdump -d testx.dll | FileCheck -check-prefix=DISASMX %s
67 DISASMX: Disassembly of section .text:
69 DISASMX-NEXT: 0000000180001000 <.text>:
70 DISASMX-NEXT: 180001000: 528000e0 mov w0, #0x7
71 DISASMX-NEXT: 180001004: d65f03c0 ret
73 DISASMX-NEXT: 180002000: 52800040 mov w0, #0x2
74 DISASMX-NEXT: 180002004: d65f03c0 ret
76 DISASMX-NEXT: 180003000: b8 03 00 00 00 movl $0x3, %eax
77 DISASMX-NEXT: 180003005: c3 retq
79 DISASMX-NEXT: Disassembly of section test:
81 DISASMX-NEXT: 0000000180006000 <test>:
82 DISASMX-NEXT: 180006000: 528000a0 mov w0, #0x5
83 DISASMX-NEXT: 180006004: d65f03c0 ret
85 DISASMX-NEXT: 180007000: b8 06 00 00 00 movl $0x6, %eax
86 DISASMX-NEXT: 180007005: c3 retq
90 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
93 RUN: llvm-readobj --coff-load-config testm.dll | FileCheck -check-prefix=CODEMAPM %s
95 CODEMAPM-NEXT: 0x1000 - 0x1010 ARM64EC
96 CODEMAPM-NEXT: 0x2000 - 0x3004 X64
99 RUN: llvm-objdump -d testm.dll | FileCheck -check-prefix=DISASMM %s
100 DISASMM: Disassembly of section .text:
102 DISASMM-NEXT: 0000000180001000 <.text>:
103 DISASMM-NEXT: 180001000: 52800040 mov w0, #0x2
104 DISASMM-NEXT: 180001004: d65f03c0 ret
105 DISASMM-NEXT: 180001008: 528000a0 mov w0, #0x5
106 DISASMM-NEXT: 18000100c: d65f03c0 ret
108 DISASMM-NEXT: 180002000: b8 03 00 00 00 movl $0x3, %eax
109 DISASMM-NEXT: 180002005: c3 retq
111 DISASMM-NEXT: 180002ffe: 00 00 addb %al, (%rax)
112 DISASMM-NEXT: 180003000: b8 06 00 00 00 movl $0x6, %eax
114 Merging data sections into code sections causes data to be separated from the code when sorting chunks.
116 RUN: lld-link -out:testdm.dll -machine:arm64ec arm64ec-func-sym.obj x86_64-func-sym.obj codemap.obj \
117 RUN: data-sec.obj loadconfig-arm64ec.obj -dll -noentry -merge:.testdata=.text -merge:.rdata=test
119 RUN: llvm-readobj --coff-load-config testdm.dll | FileCheck -check-prefix=CODEMAPDM %s
121 CODEMAPDM-NEXT: 0x2000 - 0x2008 ARM64EC
122 CODEMAPDM-NEXT: 0x3000 - 0x3006 X64
123 CODEMAPDM-NEXT: 0x5200 - 0x5208 ARM64EC
124 CODEMAPDM-NEXT: 0x6000 - 0x6006 X64
127 RUN: llvm-objdump -d testdm.dll | FileCheck -check-prefix=DISASMDM %s
128 DISASMDM: Disassembly of section .text:
130 DISASMDM-NEXT: 0000000180001000 <.text>:
131 DISASMDM-NEXT: 180001000: 00000001 udf #0x1
133 DISASMDM-NEXT: 180002000: 52800040 mov w0, #0x2
134 DISASMDM-NEXT: 180002004: d65f03c0 ret
136 DISASMDM-NEXT: 180003000: b8 03 00 00 00 movl $0x3, %eax
137 DISASMDM-NEXT: 180003005: c3 retq
139 DISASMDM-NEXT: Disassembly of section test:
141 DISASMDM-NEXT: 0000000180005000 <test>:
142 DISASMDM: 180005200: 528000a0 mov w0, #0x5
143 DISASMDM-NEXT: 180005204: d65f03c0 ret
145 DISASMDM-NEXT: 180006000: b8 06 00 00 00 movl $0x6, %eax
146 DISASMDM-NEXT: 180006005: c3 retq
148 #--- arm64-func-sym.s
150 .globl arm64_func_sym
156 #--- arm64ec-func-sym.s
158 .globl arm64ec_func_sym
165 .globl arm64ec_func_sym2
171 #--- x86_64-func-sym.s
173 .globl x86_64_func_sym
180 .globl x86_64_func_sym2
187 .section .testdata, "rd"
194 .rva arm64ec_func_sym + 1
196 .rva x86_64_func_sym + 2
198 .rva arm64ec_func_sym2 + 1
200 .rva x86_64_func_sym2 + 2
203 .globl code_map_count
212 .rva arm64ec_func_sym + 1
214 .rva x86_64_func_sym + 2
216 .rva arm64ec_func_sym2 + 1
218 .rva x86_64_func_sym2 + 2
221 .globl code_map_count
228 .rva arm64ec_func_sym + 1
230 .rva x86_64_func_sym + 2
233 .globl code_map_count