2 RUN: split-file %s %t.dir && cd %t.dir
4 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-patchable.s -o arm64ec-patchable.obj
5 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-alias.s -o arm64ec-alias.obj
6 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-sec.s -o test-sec.obj
7 RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
9 RUN: lld-link -out:test.dll -machine:arm64ec arm64ec-patchable.obj test-sec.obj loadconfig-arm64ec.obj -dll -noentry
11 RUN: llvm-objdump -d test.dll | FileCheck -check-prefix=PATCH-DISASM %s
12 PATCH-DISASM: Disassembly of section .text:
14 PATCH-DISASM-NEXT: 0000000180001000 <.text>:
15 PATCH-DISASM-NEXT: 180001000: 52800040 mov w0, #0x2 // =2
16 PATCH-DISASM-NEXT: 180001004: d65f03c0 ret
18 PATCH-DISASM-NEXT: Disassembly of section .hexpthk:
20 PATCH-DISASM-NEXT: 0000000180002000
21 PATCH-DISASM-NEXT: 180002000: 48 8b c4 movq %rsp, %rax
22 PATCH-DISASM-NEXT: 180002003: 48 89 58 20 movq %rbx, 0x20(%rax)
23 PATCH-DISASM-NEXT: 180002007: 55 pushq %rbp
24 PATCH-DISASM-NEXT: 180002008: 5d popq %rbp
25 PATCH-DISASM-NEXT: 180002009: e9 f2 ef ff ff jmp 0x180001000 <.text>
26 PATCH-DISASM-NEXT: 18000200e: cc int3
27 PATCH-DISASM-NEXT: 18000200f: cc int3
29 RUN: llvm-readobj --hex-dump=.test test.dll | FileCheck -check-prefix=RVA %s
30 RVA: 0x180006000 00200000
32 RUN: llvm-readobj --coff-load-config test.dll | FileCheck -check-prefix=PATCH-CHPE %s
34 PATCH-CHPE-NEXT: 0x1000 - 0x1008 ARM64EC
35 PATCH-CHPE-NEXT: 0x2000 - 0x2010 X64
37 PATCH-CHPE-NEXT: CodeRangesToEntryPoints [
38 PATCH-CHPE-NEXT: 0x2000 - 0x2010 -> 0x2000
40 PATCH-CHPE-NEXT: RedirectionMetadata [
41 PATCH-CHPE-NEXT: 0x2000 -> 0x1000
45 RUN: lld-link -out:test2.dll -machine:arm64ec arm64ec-alias.obj test-sec.obj loadconfig-arm64ec.obj -dll -noentry
47 RUN: llvm-objdump -d test2.dll | FileCheck -check-prefix=PATCH-DISASM %s
48 RUN: llvm-readobj --hex-dump=.test test2.dll | FileCheck -check-prefix=RVA %s
49 RUN: llvm-readobj --coff-load-config test2.dll | FileCheck -check-prefix=PATCH-CHPE %s
51 RUN: lld-link -out:test3.dll -machine:arm64ec arm64ec-alias.obj test-sec.obj loadconfig-arm64ec.obj -dll -noentry -export:patchable_func
53 RUN: llvm-objdump -d test3.dll | FileCheck -check-prefix=PATCH-DISASM %s
54 RUN: llvm-readobj --hex-dump=.test test3.dll | FileCheck -check-prefix=RVA %s
55 RUN: llvm-readobj --coff-load-config test3.dll | FileCheck -check-prefix=PATCH-CHPE %s
58 RUN: not lld-link -out:test4.dll -machine:arm64ec test-sec.obj loadconfig-arm64ec.obj -dll -noentry 2>&1 | FileCheck --check-prefix=ERR %s
59 ERR: error: undefined symbol: EXP+#patchable_func
62 #--- arm64ec-patchable.s
63 .section ".text", "x", discard, "#patchable_func$hp_target"
64 .globl "#patchable_func$hp_target"
66 "#patchable_func$hp_target":
70 .def "EXP+#patchable_func"
76 .section ".text", "x", discard, "#patchable_func$hp_target"
77 .globl "#patchable_func$hp_target"
79 "#patchable_func$hp_target":
83 .def "EXP+#patchable_func"
88 patchable_func = "EXP+#patchable_func"
91 .section ".test", "rd"
92 .rva "EXP+#patchable_func"