How to split Linux (Android) ARM64 executable into small and large parts?

南笙酒味 提交于 2021-01-05 08:52:19

问题


Background

I have an Android app which uses native ARM64 executables (essentially GCC toolchain, extracted to app directory (/data/data/%package%/somePath) on the first run) to do some work. Due to Android 10 changes files in /data/data/.. can't have executable permission anymore.

Confirmed workaround

The workaround is to make executables look like shared libraries (libsomething.so) that are extracted by Android to /data/app/%package% dir with android:extractNativeLibs="true" in AndroidManifest.xml and are allowed to have executable permission. Symlinking might be useful to mimic the previous files structure.

The problem

The problem is that all the executables (aka new "shared libs") are packed into android apk with zip compression ratio (as apk is essentially just a zip file) which could be better if it's archieved with 7zip for instance and together weight more than 100Mb which is app limitation on Android (for apk files).

The question and the proposal

How can i split the executables into a small part (that goes into /data/app/%package% and a large part (or just existing executable in /data/data/%package%)? The idea is that small executable just "loads and runs" a regular one. The benefit it that regular executable is compressed with 7zip and it makes apk size much smaller due to 7zip used with a better compression ratio.

I've been looking into direction of using of UPX but having no experience with it (note i will have to prepare executable on Mac machine (or Linux with VM or Docker) to run on Android ARM64). Also i've been thinking about creating of 7z sfx but it seems to be tricky (again, it have to be created on x86_64 and run on ARM64). Also I've found some similar QA (which recommends memexec() or fexecve()), but i'm not sure what's the optimal way to go.

Ideally i'd love to have some tiny "universal" ARM64 executable (or be able to compile it from the source code with Android NDK) that just accepts cmd and a regular executable path.

PS. App bundle and dynamic delivery modules as high-level alternatives are undesired for different reasons.

PPS. UPX did not work out of box for Android 10 (seems to be security issue).

来源:https://stackoverflow.com/questions/64947902/how-to-split-linux-android-arm64-executable-into-small-and-large-parts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!