Hitmasu / Jitex

A library to modify MSIL and native code at runtime
MIT License
120 stars 15 forks source link

Support to ARM64 #88

Closed Hitmasu closed 1 year ago

Hitmasu commented 1 year ago

Jitex doesn't run on ARM64 CPU. That's because the trampoline, which is necessary to prepare the delegate, is entirely written for X64.

https://github.com/Hitmasu/Jitex/blob/666c73ac436f8317d0b652df2898fa46efd2cfe6/src/Jitex/Utils/MemoryHelper.cs#L15-L21

Implementing a trampoline using ARM64 instructions should be sufficient.

Hitmasu commented 1 year ago

On MacOS 10.14 (Mojave) and above, Apple restricts the use of mmap with protections PROT_EXEC and PROT_WRITE. According to the official documentation, using the MAP_JIT flag should still work, but for some reason, it results in an EADDRESS.

Porting Just-In-Time Compilers to Apple Silicon

MMAP

That's necessary to allocate a native code to prepare delegate.

https://github.com/Hitmasu/Jitex/blob/666c73ac436f8317d0b652df2898fa46efd2cfe6/src/Jitex/Utils/MemoryHelper.cs#L33-L45

We will need to find another way to bypass this restriction.