LLVM Runtime Code Generation on Android

Hi,

Is there anybody out there that is experienced with run-time code generation on an android device?
Is it even possible to achieve this?

I compiled both llvm and clang for x64 android tablet and everything seemed fine until i tried to call exposed generated function through my native code: it gave an error that indicating I dont have rights to execute code in this memory block.(I will add the exact error when i access my development machine. )

My tablet is not rooted so I can not be sure that is caused by memory protection. But I would expect llvm/clang to handle memory rights that generated code resides in. right?

Thanks,
Ali

Yup, there’s even a library for it included in AOSP:

https://android.googlesource.com/platform/external/vixl/

Exception previously mentioned : “signal SIGSEGV: address access protected (fault address: 0x7f5ef23010)”

Architecture : AARCH64

@Bruce Thanks, I didn’t know such library exist. Is this library somehow related to LLVM? Actually my question was if it is possible to generate and run code with LLVM on Android(AARCH64).

I haven’t looked inside this library. The most I know about it is I need to push it onto my phone when I try to run gtest based unit tests for ART.

But if you do look inside it, perhaps you’ll get clues what needs to be done to run freshly-generated code on Android and so what maybe needs to be done to make LLVM JIT work.