mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 03:27:39 +00:00
5bd22aef12
So far I haven't found any way to run native Arm64 code on Windows Arm64 without using MSVC. When I build a PE binary from scratch that should be a valid Windows Arm64 program, the OS refuses to run it. Possibly due to requiring additional content like XML manifests or relocation or control flow integrity data that isn't normally required on x64. I've also tried using VirtualAlloc2() to JIT an Arm64 native function, but VirtualAlloc2 always fails with invalid parameter. I tried using MSVC to create an ARM DLL that my x64 emulated program can link at runtime, to pass a function pointer with ARM code, but LoadLibrary() rejects ARM DLLs as invalid exe The only option left, is likely to write a new program like ape/ape-m1.c which can be compiled by MSVC to load and run an AARCH64 ELF executable. The emulated x64 binary would detect emulation using IsWow64Process2 and then drop the loader executable in a temporary folder, and re-launch the original executable, using the Arm64 segments of the cosmocc fat binary.
8 lines
305 B
C
8 lines
305 B
C
#ifndef COSMOPOLITAN_TOOL_BUILD_ELF2PE_H_
|
|
#define COSMOPOLITAN_TOOL_BUILD_ELF2PE_H_
|
|
|
|
#define __dll_import(DLL, RET, FUNC, ARGS) \
|
|
extern RET(*const __msabi __attribute__((__weak__)) FUNC) \
|
|
ARGS __asm__("\"dll$" DLL "$" #FUNC "\"")
|
|
|
|
#endif /* COSMOPOLITAN_TOOL_BUILD_ELF2PE_H_ */
|