1
0
mirror of https://git.code.sf.net/p/mingw-w64/mingw-w64 synced 2025-04-18 17:44:18 +03:00

crt: Define metadata structures used for ARM64EC

These are populated by the linker, and then used by the loader and
emulator at runtime to allow for ARM64EC <-> X86_64 interoperability.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
Billy Laws 2023-09-14 23:36:09 +01:00 committed by Jacek Caban
parent 9b31a5346c
commit ad38e33189
3 changed files with 93 additions and 1 deletions

View File

@ -1100,6 +1100,9 @@ src_libmingwexarm64=\
math/arm64/rint.c math/arm64/rintf.c \
math/arm-common/ldexpl.c
if ARM64EC
src_libmingwexarm64+=crt/chpe.S
endif
# These intrinsics are target independent:
src_intrincs= \

85
mingw-w64-crt/crt/chpe.S Normal file
View File

@ -0,0 +1,85 @@
/**
* This file has no copyright assigned and is placed in the Public Domain.
* This file is part of the mingw-w64 runtime package.
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
*/
#define EXPORT_SYM(x) .globl x; x:
/*
* These symbols are updated at runtime by the dynamic linker to point to emulator
* helper routines.
*/
.section .00cfg, "dr"
.balign 16
EXPORT_SYM(__os_arm64x_dispatch_call_no_redirect)
.quad 0
EXPORT_SYM(__os_arm64x_dispatch_ret)
.quad 0
EXPORT_SYM(__os_arm64x_check_icall)
EXPORT_SYM(__os_arm64x_dispatch_icall)
.quad 0
EXPORT_SYM(__os_arm64x_check_call)
EXPORT_SYM(__os_arm64x_dispatch_call)
.quad 0
EXPORT_SYM(__os_arm64x_check_icall_cfg)
EXPORT_SYM(__os_arm64x_check_dispatch_cfg)
.quad 0
EXPORT_SYM(__os_arm64x_rdtsc)
EXPORT_SYM(__os_arm64x_get_x64_information)
.quad 0
EXPORT_SYM(__os_arm64x_set_x64_information)
EXPORT_SYM(__os_arm64x_cpuidex)
.quad 0
EXPORT_SYM(__os_arm64x_x64_jump)
EXPORT_SYM(__os_arm64x_dispatch_fptr)
.quad 0
EXPORT_SYM(__os_arm64x_helper3)
.quad 0
EXPORT_SYM(__os_arm64x_helper4)
.quad 0
EXPORT_SYM(__os_arm64x_helper5)
.quad 0
EXPORT_SYM(__os_arm64x_helper6)
.quad 0
EXPORT_SYM(__os_arm64x_helper7)
.quad 0
EXPORT_SYM(__os_arm64x_helper8)
.quad 0
/*
* This structure is read at runtime by the dynamic linker on ARM64EC to configure
* metadata necessary for EC code to interface with x86_64 code.
*/
.section .rdata,"dr"
.balign 16
EXPORT_SYM(__chpe_metadata)
.long 1 /* Version */
.rva __hybrid_code_map /* CodeMap */
.long __hybrid_code_map_count /* CodeMapCount */
.rva __x64_code_ranges_to_entry_points /* CodeRangesToEntryPoints */
.rva __arm64x_redirection_metadata /* RedirectionMetadata */
.rva __os_arm64x_dispatch_call_no_redirect /* __os_arm64x_dispatch_call_no_redirect */
.rva __os_arm64x_dispatch_ret /* __os_arm64x_dispatch_ret */
.rva __os_arm64x_check_call /* __os_arm64x_dispatch_call */
.rva __os_arm64x_check_icall /* __os_arm64x_dispatch_icall */
.rva __os_arm64x_check_icall_cfg /* __os_arm64x_dispatch_icall_cfg */
.rva __arm64x_native_entrypoint /* AlternateEntryPoint */
.rva __hybrid_auxiliary_iat /* AuxiliaryIAT */
.long __x64_code_ranges_to_entry_points_count /* CodeRangesToEntryPointsCount */
.long __arm64x_redirection_metadata_count /* RedirectionMetadataCount */
.rva __os_arm64x_get_x64_information /* GetX64InformationFunctionPointer */
.rva __os_arm64x_set_x64_information /* SetX64InformationFunctionPointer */
.rva __arm64x_extra_rfe_table /* ExtraRFETable */
.long __arm64x_extra_rfe_table_size /* ExtraRFETableSize */
.rva __os_arm64x_x64_jump /* __os_arm64x_dispatch_fptr */
.rva __hybrid_auxiliary_iat_copy /* AuxiliaryIATCopy */
.rva __hybrid_auxiliary_delayload_iat
.rva __hybrid_auxiliary_delayload_iat_copy
.long __hybrid_image_info_bitfield
.rva __os_arm64x_helper3
.rva __os_arm64x_helper4
.rva __os_arm64x_helper5
.rva __os_arm64x_helper6
.rva __os_arm64x_helper7
.rva __os_arm64x_helper8

View File

@ -7,7 +7,7 @@
/*
This assembly source file defines the `_load_config_used` structure, which is
purely data. The main purpose is to include the metadata necessary for enabling
Control Flow Guard (CFGuard).
Control Flow Guard (CFGuard) and ARM64EC.
Many of the symbols referenced here are supplied by the linker. This file has
been constructed with LLVM/LLD in mind.
@ -105,7 +105,11 @@ SYM(_load_config_used):
PTR CFGSYM(__guard_longjmp_table) /* GuardLongJumpTargetTable */
PTR CFGSYM(__guard_longjmp_count) /* GuardLongJumpTargetCount */
PTR 0 /* DynamicValueRelocTable */
#if defined(__arm64ec__)
PTR SYM(__chpe_metadata) /* CHPEMetadataPointer */
#else
PTR 0 /* CHPEMetadataPointer */
#endif
PTR 0 /* GuardRFFailureRoutine */
PTR 0 /* GuardRFFailureRoutineFunctionPointer */
.long 0 /* DynamicValueRelocTableOffset */