android linker和indirection function(IFUNC)

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: 00000000000bf41c    12 IFUNC   LOCAL  DEFAULT   11 __dl_strlen
  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值