Files
clang-p2996/lld/test/COFF/arm64ec.test
Jacek Caban 5b0572875c [LLD][COFF] Add support for including native ARM64 objects in ARM64EC images (#137653)
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.
2025-05-15 11:38:24 +02:00

91 lines
4.4 KiB
Plaintext

REQUIRES: aarch64, x86
RUN: split-file %s %t.dir && cd %t.dir
RUN: llvm-mc -filetype=obj -triple=aarch64-windows arm64-data-sym.s -o arm64-data-sym.obj
RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-data-sym.s -o arm64ec-data-sym.obj
RUN: llvm-mc -filetype=obj -triple=x86_64-windows x86_64-data-sym.s -o x86_64-data-sym.obj
RUN: llvm-mc -filetype=obj -triple=i686-windows x86_64-data-sym.s -o i686-data-sym.obj
RUN: llvm-cvtres -machine:arm64x -out:arm64x-resource.obj %S/Inputs/resource.res
RUN: lld-link -out:test.dll -machine:arm64ec arm64ec-data-sym.obj -dll -noentry
RUN: llvm-readobj --file-headers test.dll | FileCheck -check-prefix=ARM64EC-HEADER %s
ARM64EC-HEADER: Format: COFF-x86-64
ARM64EC-HEADER-NEXT: Arch: x86_64
ARM64EC-HEADER-NEXT: AddressSize: 64bit
ARM64EC-HEADER: Machine: IMAGE_FILE_MACHINE_AMD64 (0x8664)
RUN: lld-link -out:test.dll -machine:arm64x arm64x-resource.obj -dll -noentry
RUN: llvm-readobj --file-headers test.dll | FileCheck -check-prefix=ARM64X-HEADER %s
ARM64X-HEADER: Machine: IMAGE_FILE_MACHINE_ARM64 (0xAA64)
arm64x object files are allowed with -machine:arm64 as well
RUN: lld-link -out:test.dll -machine:arm64 arm64x-resource.obj -dll -noentry
RUN: lld-link -out:test.dll -machine:arm64ec arm64ec-data-sym.obj x86_64-data-sym.obj \
RUN: arm64x-resource.obj -dll -noentry
RUN: llvm-readobj --file-headers test.dll | FileCheck -check-prefix=ARM64EC-HEADER %s
RUN: llvm-readobj --hex-dump=.data test.dll | FileCheck -check-prefix=ARM64EC-DATA %s
ARM64EC-DATA: 02020202 03030303
RUN: lld-link -out:test.dll -machine:arm64x x86_64-data-sym.obj arm64-data-sym.obj \
RUN: arm64ec-data-sym.obj arm64x-resource.obj -dll -noentry
RUN: llvm-readobj --file-headers test.dll | FileCheck -check-prefix=ARM64X-HEADER %s
RUN: llvm-readobj --hex-dump=.data test.dll | FileCheck -check-prefix=ARM64X-DATA %s
ARM64X-DATA: 03030303 01010101 02020202
RUN: lld-link -out:test.dll -machine:arm64ec x86_64-data-sym.obj arm64-data-sym.obj \
RUN: arm64ec-data-sym.obj arm64x-resource.obj -dll -noentry
RUN: llvm-readobj --file-headers test.dll | FileCheck -check-prefix=ARM64EC-HEADER %s
RUN: llvm-readobj --hex-dump=.data test.dll | FileCheck -check-prefix=ARM64X-DATA %s
RUN: not lld-link -out:test.dll -machine:arm64 arm64-data-sym.obj arm64ec-data-sym.obj \
RUN: -dll -noentry 2>&1 | FileCheck -check-prefix=INCOMPAT1 %s
INCOMPAT1: lld-link: error: arm64ec-data-sym.obj: machine type arm64ec conflicts with arm64
RUN: not lld-link -out:test.dll -machine:arm64 arm64-data-sym.obj x86_64-data-sym.obj \
RUN: -dll -noentry 2>&1 | FileCheck -check-prefix=INCOMPAT3 %s
INCOMPAT3: lld-link: error: x86_64-data-sym.obj: machine type x64 conflicts with arm64
arm64ec machine type can't be inferred, it must be specified explicitly.
RUN: not lld-link -out:test.dll arm64ec-data-sym.obj \
RUN: -dll -noentry 2>&1 | FileCheck -check-prefix=INCOMPAT4 %s
INCOMPAT4: lld-link: error: arm64ec-data-sym.obj: machine type arm64ec is ambiguous and cannot be inferred, use /machine:arm64ec or /machine:arm64x
RUN: not lld-link -out:test.dll x86_64-data-sym.obj arm64ec-data-sym.obj \
RUN: -dll -noentry 2>&1 | FileCheck -check-prefix=INCOMPAT4 %s
RUN: not lld-link -out:test.dll arm64-data-sym.obj arm64ec-data-sym.obj \
RUN: -dll -noentry 2>&1 | FileCheck -check-prefix=INCOMPAT4 %s
RUN: not lld-link -out:test.dll i686-data-sym.obj arm64ec-data-sym.obj \
RUN: -dll -noentry 2>&1 | FileCheck -check-prefix=INCOMPAT5 %s
INCOMPAT5: lld-link: error: arm64ec-data-sym.obj: machine type arm64ec conflicts with x86
arm64x can be inferred and when mixed with ARM64, the first one wins
RUN: lld-link -out:test.dll -dll -noentry arm64x-resource.obj arm64-data-sym.obj x86_64-data-sym.obj arm64ec-data-sym.obj
RUN: not lld-link -out:test.dll -dll -noentry arm64-data-sym.obj arm64x-resource.obj x86_64-data-sym.obj 2>&1 | FileCheck -check-prefix=INCOMPAT3 %s
RUN: not lld-link -out:test.dll -dll -noentry arm64-data-sym.obj arm64x-resource.obj arm64ec-data-sym.obj 2>&1 | FileCheck -check-prefix=INCOMPAT4 %s
#--- arm64ec-data-sym.s
.data
.globl arm64ec_data_sym
.p2align 2, 0x0
arm64ec_data_sym:
.word 0x02020202
#--- arm64-data-sym.s
.data
.globl arm64_data_sym
.p2align 2, 0x0
arm64_data_sym:
.word 0x01010101
#--- x86_64-data-sym.s
.data
.globl x86_64_data_sym
.p2align 2, 0x0
x86_64_data_sym:
.long 0x03030303