1

I have a compiled aarch64 shared library (my_custom.so) that has been successfully integrated into an APK and runs on Android devices. As it is a standalone low-level computational library without dependencies on Android system components

I am exploring the possibility of creating a Linux aarch64 executable that incorporates this library. This would enable the same functionality on the server side, serving as an alternative to Android devices, leveraging the common aarch64 architecture

Regrettably, the source code for my_custom.so is lost.

I have confirmed through commands such as ldd and readelf that my_custom.so only depends on libc.so, libc++_shared.so, liblog.so, and libz.so.

However, there is an error indicating that the library /lib64/libc.so has an invalid ELF header: "/lib64/libc.so invalid elf header."

After using the cat command, I confirmed that /lib64/libc.so is actually a text file, and the actual library file is /lib64/libc.so.6. When I attempted to create a symbolic link from /lib64/libc.so to /lib64/libc.so.6, I encountered an error stating: version glibc not found.

I speculate that this discrepancy might be due to my_custom.so being compiled with NDK that uses a different libc library than the one present in my current Linux aarch64 environment. Therefore, I attempted to locate the corresponding libc library in the NDK's platform directory.

I copied libc.so from NDK's platforms dir and loaded it before my_custom.so, but faced a **"not page-aligned" **error. Research on Google suggests it might be due to libraries not aligning with the larger page size. As the current system's memory page size is unmodifiable, I'm now looking for alternative versions of libc.so

After copying libc.so from /toolchains/llvm/prebuilt/ in the NDK, I verified it with ldd. I also copied libc++_shared.so from the llvm directory, and it passed ldd verification as well.

However, when I ran the entire program, it resulted in a core dump...

I want to know if it's possible to run a .so library (compiled by NDK for Android aarch64) on Linux aarch64. If it is possible, is my approach correct, and what should I do next?

I speculate that utilizing technologies like QEMU or Anbox to run an Android virtual machine on Linux might be a feasible solution. However, considering that my_custom.so doesn't depend on any Android system components, I find the virtual machine approach relatively complex and resource-intensive, leading to potential resource wastage.

2 Answers 2

1

As it is a standalone low-level computational library without dependencies on Android system components

Your premise is wrong. It depends on the Android loader and C library. It will not run on a GNU system.

Sign up to request clarification or add additional context in comments.

Comments

0

I want to know if it's possible to run a .so library (compiled by NDK for Android aarch64) on Linux aarch64. If it is possible, is my approach correct, and what should I do next?

It is not utterly impossible, but it is difficult, complicated and fragile. I have done it, briefly, but the aarch64 VM I used stopped working quite quickly and I abandoned the idea.

The best course of action for you is to reconstruct the source for my_custom.so. Having that will let you build proper versions for Linux.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.