
MSVC linker accepts native ARM64 object files as input with `-machine:arm64ec`, similar to `-machine:arm64x`. Its usefulness is very limited; for example, both exports and imports are not reflected in the PE structures and can't work. However, their symbol tables are otherwise functional. Since we already have handling of multiple symbol tables implemented for ARM64X, the required changes are mostly about adjusting relevant checks to account for them on the ARM64EC target. Delay-load helper handling is a bit of a shortcut. The patch never pulls it for native object files and just ensures that the code is fine with that. In general, I think it would be nice to adjust the driver to pull it only when it's actually referenced, which would allow applying the same logic to the native symbol table on ARM64EC without worrying about pulling too much.
106 lines
4.3 KiB
Plaintext
106 lines
4.3 KiB
Plaintext
REQUIRES: aarch64, x86
|
|
RUN: split-file %s %t.dir && cd %t.dir
|
|
|
|
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-patchable.s -o arm64ec-patchable.obj
|
|
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-alias.s -o arm64ec-alias.obj
|
|
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows test-sec.s -o test-sec.obj
|
|
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows %S/Inputs/loadconfig-arm64ec.s -o loadconfig-arm64ec.obj
|
|
RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj
|
|
|
|
RUN: lld-link -out:test.dll -machine:arm64ec arm64ec-patchable.obj test-sec.obj loadconfig-arm64ec.obj -dll -noentry
|
|
|
|
RUN: llvm-objdump -d test.dll | FileCheck -check-prefix=PATCH-DISASM %s
|
|
PATCH-DISASM: Disassembly of section .text:
|
|
PATCH-DISASM-EMPTY:
|
|
PATCH-DISASM-NEXT: 0000000180001000 <.text>:
|
|
PATCH-DISASM-NEXT: 180001000: 52800040 mov w0, #0x2 // =2
|
|
PATCH-DISASM-NEXT: 180001004: d65f03c0 ret
|
|
PATCH-DISASM-EMPTY:
|
|
PATCH-DISASM-NEXT: Disassembly of section .hexpthk:
|
|
PATCH-DISASM-EMPTY:
|
|
PATCH-DISASM-NEXT: 0000000180002000
|
|
PATCH-DISASM-NEXT: 180002000: 48 8b c4 movq %rsp, %rax
|
|
PATCH-DISASM-NEXT: 180002003: 48 89 58 20 movq %rbx, 0x20(%rax)
|
|
PATCH-DISASM-NEXT: 180002007: 55 pushq %rbp
|
|
PATCH-DISASM-NEXT: 180002008: 5d popq %rbp
|
|
PATCH-DISASM-NEXT: 180002009: e9 f2 ef ff ff jmp 0x180001000 <.text>
|
|
PATCH-DISASM-NEXT: 18000200e: cc int3
|
|
PATCH-DISASM-NEXT: 18000200f: cc int3
|
|
|
|
RUN: llvm-readobj --hex-dump=.test test.dll | FileCheck -check-prefix=RVA %s
|
|
RVA: 0x180006000 00200000
|
|
|
|
RUN: llvm-readobj --coff-load-config test.dll | FileCheck -check-prefix=PATCH-CHPE %s
|
|
PATCH-CHPE: CodeMap [
|
|
PATCH-CHPE-NEXT: 0x1000 - 0x1008 ARM64EC
|
|
PATCH-CHPE-NEXT: 0x2000 - 0x2010 X64
|
|
PATCH-CHPE-NEXT: ]
|
|
PATCH-CHPE-NEXT: CodeRangesToEntryPoints [
|
|
PATCH-CHPE-NEXT: 0x2000 - 0x2010 -> 0x2000
|
|
PATCH-CHPE-NEXT: ]
|
|
PATCH-CHPE-NEXT: RedirectionMetadata [
|
|
PATCH-CHPE-NEXT: 0x2000 -> 0x1000
|
|
PATCH-CHPE-NEXT: ]
|
|
|
|
|
|
RUN: lld-link -out:test2.dll -machine:arm64ec arm64ec-alias.obj test-sec.obj loadconfig-arm64ec.obj -dll -noentry
|
|
|
|
RUN: llvm-objdump -d test2.dll | FileCheck -check-prefix=PATCH-DISASM %s
|
|
RUN: llvm-readobj --hex-dump=.test test2.dll | FileCheck -check-prefix=RVA %s
|
|
RUN: llvm-readobj --coff-load-config test2.dll | FileCheck -check-prefix=PATCH-CHPE %s
|
|
|
|
RUN: lld-link -out:test3.dll -machine:arm64ec arm64ec-alias.obj test-sec.obj loadconfig-arm64ec.obj -dll -noentry -export:patchable_func
|
|
|
|
RUN: llvm-objdump -d test3.dll | FileCheck -check-prefix=PATCH-DISASM %s
|
|
RUN: llvm-readobj --hex-dump=.test test3.dll | FileCheck -check-prefix=RVA %s
|
|
RUN: llvm-readobj --coff-load-config test3.dll | FileCheck -check-prefix=PATCH-CHPE %s
|
|
|
|
|
|
RUN: not lld-link -out:test4.dll -machine:arm64ec test-sec.obj loadconfig-arm64ec.obj -dll -noentry 2>&1 | FileCheck --check-prefix=ERR %s
|
|
ERR: error: undefined symbol: EXP+#patchable_func (EC symbol)
|
|
|
|
|
|
RUN: lld-link -out:testx.dll -machine:arm64x arm64ec-patchable.obj test-sec.obj \
|
|
RUN: loadconfig-arm64.obj loadconfig-arm64ec.obj -dll -noentry
|
|
RUN: llvm-objdump -d testx.dll | FileCheck -check-prefix=PATCH-DISASM %s
|
|
RUN: llvm-readobj --coff-load-config testx.dll | FileCheck -check-prefix=PATCH-CHPE %s
|
|
|
|
|
|
RUN: lld-link -out:testx2.dll -machine:arm64x arm64ec-alias.obj loadconfig-arm64.obj \
|
|
RUN: loadconfig-arm64ec.obj -dll -noentry
|
|
RUN: llvm-objdump -d testx2.dll | FileCheck -check-prefix=PATCH-DISASM %s
|
|
RUN: llvm-readobj --coff-load-config testx2.dll | FileCheck -check-prefix=PATCH-CHPE %s
|
|
|
|
|
|
#--- arm64ec-patchable.s
|
|
.section ".text", "x", discard, "#patchable_func$hp_target"
|
|
.globl "#patchable_func$hp_target"
|
|
.p2align 2, 0x0
|
|
"#patchable_func$hp_target":
|
|
mov w0, #2
|
|
ret
|
|
|
|
.def "EXP+#patchable_func"
|
|
.scl 2
|
|
.type 32
|
|
.endef
|
|
|
|
#--- arm64ec-alias.s
|
|
.section ".text", "x", discard, "#patchable_func$hp_target"
|
|
.globl "#patchable_func$hp_target"
|
|
.p2align 2, 0x0
|
|
"#patchable_func$hp_target":
|
|
mov w0, #2
|
|
ret
|
|
|
|
.def "EXP+#patchable_func"
|
|
.scl 2
|
|
.type 32
|
|
.endef
|
|
.weak patchable_func
|
|
patchable_func = "EXP+#patchable_func"
|
|
|
|
#--- test-sec.s
|
|
.section ".test", "rd"
|
|
.rva "EXP+#patchable_func"
|