Android IFUNC支持
IFUNC概念
参考 GNU_IFUNC。
Android支持限制
在 Android linker changes for NDK developers 中描述,android api>=29才支持该特性:
Use of IFUNC in libc (True for all API levels on devices running Q)
Starting with Android Q (API level 29), libc uses IFUNC functionality in the dynamic linker to choose optimized assembler routines at run time rather than at build time. This lets us use the same libc.so on all devices, and is similar to what other OSes already did. Because the zygote uses the C library, this decision is made long before we know what API level an app targets, so all code sees the new IFUNC-using C library. Most apps should be unaffected by this change, but apps that hook or try to detect hooking of C library functions might need to fix their code to cope with IFUNC relocations. The affected functions are from <string.h>, but may expand to include more functions (and more libraries) in future.
而且到目前为止,只有<string.h>的函数才使用了该特性。
这从linker64 DSO中就可以看到:
xuwakao@chiefhsing-PC:~/android-11.0.0_r29/out/target/product/crosshatch$ ~/Android/Sdk/ndk/20.0.5594570/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/readelf -s ./apex/com.android.runtime/bin/linker64 | grep 'IFUNC'
6993: 00000000000bf404 12 IFUNC LOCAL DEFAULT 11 __dl_strchr
6994: 00000000000bf410 12 IFUNC LOCAL DEFAULT 11 __dl_strcmp
6995: 00000000

本文探讨了Android系统中IFUNC(Indirect Function)的概念及其在API级别29及以上版本的支持情况。IFUNC允许动态链接器在运行时选择优化的汇编程序,以提高性能。主要介绍了IFUNC在Android链接器中的实现,涉及LLVM和逆向分析,并通过实例展示了如何定义和解析IFUNC函数。结论指出,IFUNC的使用减少了针对不同设备的编译选项,简化了库文件管理。
最低0.47元/天 解锁文章
1923

被折叠的 条评论
为什么被折叠?



