Android 中共享库的剥离部分 header
Stripping section header of shared library in Android
我在 Android 上有一个 Java + NDK 项目,其中 CMakeLists.txt
文件用于共享库,我想删除 .so 文件的 headers 部分。我通过在 CMakeLists.txt
文件中使用 add_custom_command
添加为 POST_BUILD
来使用 sstrip
和其他一些工具。编译后我看到修补程序(sstrip 等)正常工作,但我收到类似 lib.so: File truncated
的错误并且应用程序根本没有 运行 因为它无法加载 .so 文件。我刚刚在 Android 工作室的 运行 终端上收到 Application terminated
消息。
即使我更改了部分 headers 中的某些值而不删除它们,我也会收到类似的错误。
AFAIK 部分 headers 不需要执行或动态加载。
为什么应用 运行 没有部分 headers?
您不能删除那些 headers (source)
:
Each ELF file has additional information contained in the section headers. These headers must be present now, because the dynamic linker uses them for sanity checking. Some developers try to strip them in an attempt to obfuscate the binary and prevent reverse engineering. (This doesn’t really help because it is possible to reconstruct the stripped information using widely-available tools.)
我在 Android 上有一个 Java + NDK 项目,其中 CMakeLists.txt
文件用于共享库,我想删除 .so 文件的 headers 部分。我通过在 CMakeLists.txt
文件中使用 add_custom_command
添加为 POST_BUILD
来使用 sstrip
和其他一些工具。编译后我看到修补程序(sstrip 等)正常工作,但我收到类似 lib.so: File truncated
的错误并且应用程序根本没有 运行 因为它无法加载 .so 文件。我刚刚在 Android 工作室的 运行 终端上收到 Application terminated
消息。
即使我更改了部分 headers 中的某些值而不删除它们,我也会收到类似的错误。
AFAIK 部分 headers 不需要执行或动态加载。 为什么应用 运行 没有部分 headers?
您不能删除那些 headers (source) :
Each ELF file has additional information contained in the section headers. These headers must be present now, because the dynamic linker uses them for sanity checking. Some developers try to strip them in an attempt to obfuscate the binary and prevent reverse engineering. (This doesn’t really help because it is possible to reconstruct the stripped information using widely-available tools.)