-
-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library corruption with armv7 android library when soname changed #215
Comments
Could you try with patchelf 0.11? |
@domenkozar problem still happens with patchelf 0.11. |
Can confirm with 0.10, patchelf corrupts the library when using --set-soname or --add-needed. Readelf output contains this error: |
Still happens with 0.11 |
Someone needs to bisect between 0.9 and 0.10 |
If I have git bisected properly then c4deb5e is causing the problem Edit: |
Seems fixed in 0.12 |
Fixed for some libs, still happens with others |
While I was debugging other strange crashes with patched binaries a colleague found at least one issue: the Linux kernel assumes the bss is located after the last LOAD segment. When introducing a new one and moving things around this will lead to the bss not being last, and so it will not be zeroed out. If your static variables are suddenly random junk on startup you are doomed… |
Describe the bug
I used this tool to patch the soname attribute in an armv7 Android library. The tool was used temporarily as a stop-gap measure to avoid renaming a library in our build infrastructure.
The patched library functioned normally until a C++ exception was thrown, and then it would cause a runtime abort and corrupt the stack. I attempted to debug the problem on an armv7 Android emulator, but the problem would cause the emulator itself to crash. The problem did not happen with x86 or arm64 under the same circumstances.
When I would rename and produce the armv7 library I needed as part of our build (so eliminate the patchelf step), the problem went away entirely.
The library format is as follows via the
file
command:Steps To Reproduce
This is the command I used (run on macOS):
# rename and patch to the soname we need... mv libtestlibrary.so libtestlibrary_armeabi-v7a.so patchelf --set-soname libtestlibrary_armeabi-v7a.so libtestlibrary_armeabi-v7a.so
During runtime everything worked correctly, until a C++ exception was thrown and then the app would abort. Here is an example of the output captured with logcat. To be clear, the exception is handled, so the error message is misleading that it is an uncaught exception.
Expected behavior
Not have modified runtime behavior.
Version Information
patchelf --version
outputVersion output:
patchelf 0.10
I tested with this specific commit, which was the latest at time I built the tool
https://github.com/NixOS/patchelf/tree/978325def61e0126d13d7936eee51326cbd433d4
Additional context
The patched library was built with Android NDK r20 (clang 8.0.7). I tested with r20b as well but it made no difference.
The text was updated successfully, but these errors were encountered: