unicorn
unicorn copied to clipboard
Bug fix for java binding of Apple silicon.
Because Java also has JIT code, Java binding in Apple M1 does not execute "tb_exec_lock" at the end of execution, which will cause "SIGBUS" exception in the execution of JIT code in Java.
I don't think it's the correct way to fix though it might solve your issue for now. Why is java special in this case?
The java code will also be converted into local code by jit. When the unicorn execution is completed, if pthread_jit_write_protect is not called, the jit at the java layer will fail to execute.
This PR also fixed my unicorn bindings crashing in .NET 6 on a M1 Macbook Air. Would be great to get fixed.
Edit: If you want to repro the (most likely same) issue, I have my bindings with an example application (UnicornNet.App) https://github.com/AeonLucid/UnicornNet/tree/uc2 (branch uc2). Make sure to put your MacOS Arm64 dylib into UnicornNet/Libs/arm64, or hack it to your own path UcNative.cs#L44. The one provided in my repository currently has this PR, so to reproduce replace with 2.0.0.
It's quite unclear to me how these fixes work without an M1 test environment. I can review this probably after I get one for debugging.
Not stale.
Applied the correct fix here: 6e97e59f5416e2cd3ad7d476061d9f7dc38eb66c