android 6.0 and sdk23, when used xx.so has text relocations. bug

本文介绍了解决Android开发中SO文件存在的内存浪费和安全风险问题的方法。通过调整编译选项,如添加-fPIC标志来确保共享库正确编译,避免了文本重定位错误,提升了应用的安全性和性能。

linker mylib.so has text relocations. This is wasting memory and is a security risk. Please fix.


1. add -static -fPIC to .a lib build compile flags
2. android so Android.mk
LOCAL_CFLAGS += -shared -fPIC
LOCAL_LDFLAGS += -shared -fPIC

eu-findtextrel xx.so 

suker@suker-Lenovo-Y430P:armeabi$ eu-findtextrel xx.so 
either the file containing the function 'xxx_arm' or the file containing the function '__cxa_thread_atexit' is not compiled with -fpic/-fPIC
...

fixed build option

until
suker@suker-Lenovo-Y430P:armeabi$ eu-findtextrel xx.so 
eu-findtextrel: no text relocations reported in 'xx.so'
suker@suker-Lenovo-Y430P:armeabi$ 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值