We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi,
The latest 64-bit architecture can on both AArch64 and AArch32 state.
Can someone tell me how to utilize this feature so that I can seamlessly integrate algorithms (which are optimized with 32-bit and 64-bit instructions) with applications which are build for 32-bit and 64-bit modes.
Here is the specifics of situation which I am facing right now.
I want to link an ARM shared library which is optimized with 64-bit instructions with my application which is built in 32 bit mode.
At the time of linking I am getting the following error. "skipping incompatible xxxx.so file".
My build environment is android and unfortunately I don't have the option to build my application in 64-bit mode.
Appreciate your help with inputs.
Thanks, Prasad
It is not possible to link a 64-bit library with a 32-bit application.
In ARMv8, interworking between 64-bit execution state (AArch64) and 32-bit execution state (AArch32) happens only at boundaries between exception levels (that is, privilege levels). So you can execute a 32-bit application -- linked with 32-bit libraries -- at the lowest execution level (EL0) within the context of a 64-bit operating system at the kernel execution level (EL1). By the way, the converse is not true -- you cannot run 64-bit applications under a 32-bit operating system.
So when creating your application you have to choose: 32-bit or 64-bit. This does also mean that if you want your operating system to support both 32-bit and 64-bit then you must have both 32-bit and 64-bit libraries.
As I understand it, this is the same for other major architectures that support both 32-bit and 64-bit operation, though I could be wrong.
It also depends on whether your hardware supports both AArch32 and AArch64 at all exception levels. The Cortex processors from ARM do, but not all ARMv8-A processors support all the combinations. See section D1.20 of the "ARM Architecture Reference Manual, ARMv8, for ARMv8-A architecture profile" manual for more details.
If the hardware supports AArch32 and AArch64 at all exception levels then the RMR_ELx register (where x is the highest implemented exception level, typically x=3) might be used to switch the execution state at the highest exception level by resetting the processor. But that assumes you have access to the highest exception level. (EL3 is 2 levels above where the OS kernel executes, for example).
I think that is the right reply for this question. It just isn't possible in Android and I don't think anyone plans to support anything like that. The most that happens like that is that a driver or system routine can be in 64 bit mode and be invoked by a 32 bit application. You an do like you say with 32 bit ARM and Thumb code but the overall environment doesn't change when one does that.
If the library task is a longish one you might be able to pipe the data between a process in 32 bit mode and one in 64 bit mode. It sounds though like you have very little control over the 32 bit application.
There is a 32 bit mode using the 64 bit instructions being developed, but I don't think it will be on Android and its main purposes are to simplify porting 32 bit legacy code with less baggage and to run some benchmark tests in a way that'll produce compatible results with x86 chips. It would need a different library too but the changes would be less than backporting to ARM 32 bit code.