From: Billy Laws <blaw...@gmail.com> These are populated by the linker, and then used by the loader and emulator at runtime to allow for ARM64EC <-> X86_64 interoperability. --- mingw-w64-crt/Makefile.am | 3 ++ mingw-w64-crt/crt/chpe.S | 85 +++++++++++++++++++++++++++++++++++++ mingw-w64-crt/crt/loadcfg.S | 6 ++- 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 mingw-w64-crt/crt/chpe.S
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am index 291d24b24..f00e701f9 100644 --- a/mingw-w64-crt/Makefile.am +++ b/mingw-w64-crt/Makefile.am @@ -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= \ diff --git a/mingw-w64-crt/crt/chpe.S b/mingw-w64-crt/crt/chpe.S new file mode 100644 index 000000000..8311da132 --- /dev/null +++ b/mingw-w64-crt/crt/chpe.S @@ -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 diff --git a/mingw-w64-crt/crt/loadcfg.S b/mingw-w64-crt/crt/loadcfg.S index f907a1842..5aba73462 100644 --- a/mingw-w64-crt/crt/loadcfg.S +++ b/mingw-w64-crt/crt/loadcfg.S @@ -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 */ -- 2.49.0 _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public