has text relocations

Original: http://www.itdadao.com/articles/c15a324479p0.html


In the Android 6.0+ system, when TargetAPI>22 when app is compiled, the problem of has text relocations when loading some so is handled:

You can use the eu-findtextrel command in the Linux system to check where the problem is, as follows:

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$ 


Note: Sometimes the -fPIC option is added to compile, but a warning prompt box still appears. At this time, it may be caused by the assembly code of some libraries. You can recompile with --disable-asm.

Guess you like

Origin blog.csdn.net/gouguofei/article/details/77085533