R
R
Rou19972017-02-20 00:28:01
Android
Rou1997, 2017-02-20 00:28:01

Android NDK: Is there a case in objcopy from Android NDK or ARM SDK that --redefine-sym works? Do you know if this is a bug or what?

There is an ELF library, ARM v7 architecture, you need to rename the function.
1.
readelf --syms libToClone.so
Conclusion:

...
     9: 00000550    55 FUNC    GLOBAL DEFAULT    7 Java_com_ourconcurrent_MainActivity_wonderFoo
...

2.
objcopy --redefine-sym Java_com_ourconcurrent_MainActivity_wonderFoo=Java_com_rou1997_MainActivity_wonderFoo libToClone.so libResult.so

Conclusion:
3. Again:
readelf --syms libResult.so
Conclusion:
...
     9: 00000550    55 FUNC    GLOBAL DEFAULT    7 Java_com_ourconcurrent_MainActivity_wonderFoo
...

Not only was the function not renamed, the files have the same checksums.
I tried different functions, including "normal" ones without JNIEXPORT.
Tried to rename without changing the length of the symbol name.
Toolchains are also different, arm 4.9, arm 4.8 and x86.
I also tried not to specify the name of the output file, so that it is saved to the same one.
Nothing changes.
Tried other platforms.
On UNIX - works.
In MinGW - does not work.
OS X - TODO.
If this really doesn’t work at all in Android NDK, then you will either have to use desktop Linux, that is, a “non-native” toolchain, and this is not entirely correct for Android ELF, and it didn’t work at all (“Unable to recognize the format of the input file ", although readelf works), or write something of your own to work with ELF, and this is a long time.
UPD: Similar issue with GNU ARM Embedded Toolchain , only the CRC changes.
UPD #2: --strip-symboldoesn't work anywhere else listed either.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question