How to rename dynamic symbols in arm elf .so file?

Viewed 3055

I need to modify a so inside an Android APK. The task is to rename the dynamic symbols in side the so (which is the function name).

For example, change from Java_com_example_abc_.... to Java_com_yahoo_zzz_....

I try to use WinHex directly search and replace text words, the apk startup error. Seems like the .hash section also needs to be updated, but i do not know how to update the .hash section.

My question is what is the correct or preferable way to rename the dynamic Symbol?

I heave been stuck for 3 days, please help me, thank you very much!

Found a post might related, but he didn't gave the alternative solution. https://sourceware.org/ml/binutils/2006-03/msg00266.html

2 Answers

Have a look at LIEF, but try to keep them the same length

native_lib = 'my_native_lib.so'
lib = lief.parse(native_lib)
for x in lib.exported_symbols:
    if x.name == 'Java_com_example_abc':
        x.name = 'Java_com_foobarr_zzz'
lib.write(native_lib)  # overwrite
Related