Skip to content
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

Exclude libgcc and libunwind from linked libraries on Android. #704

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

mgautierfr
Copy link
Member

@mgautierfr mgautierfr commented Jun 4, 2024

As said in [1], unwinder is linked automatically by Clang and shared library must not re-export it.

ndk after r23 (we are using r21) should do this. Else we must take care to not re-export it.

From [2], we should pass the flags Wl,--exclude-libs,libgcc.a and -Wl,--exclude-libs,libunwind.a to avoid re-export _Unwind_Resume methods.

Fix kiwix/kiwix-android#3661

[1] https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Unwinding
[2] android/ndk#889 (comment)

As said in [1], unwinder is linked automatically by Clang and shared
library must not re-export it.

ndk after r23 (we are using r21) should be this. Else we must take care to
not re-export it.

From [2], we should pass the flags `Wl,--exclude-libs,libgcc.a` and
`-Wl,--exclude-libs,libunwind.a` to avoid re-export `_Unwind_Resume` methods.

Fix kiwix/kiwix-android#3661

[1] https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Unwinding
[2] android/ndk#889 (comment)
@kelson42
Copy link
Contributor

kelson42 commented Jun 4, 2024

@mgautierfr I guess it fixes the unwind error, but not the crash scenario?

@mgautierfr
Copy link
Member Author

@MohitMaliFtechiz, can you test with build libraries in https://tmp.kiwix.org/ci/dev_preview/fix_android_compilation please ?

I guess it fixes the unwind error, but not the crash scenario?

The crash is due to the broken unwind. So it also fixes the crash.
A small repro case made by @MohitMaliFtechiz now don't crash on my side with this fix.

@MohitMaliFtechiz
Copy link

MohitMaliFtechiz commented Jun 5, 2024

@mgautierfr, @kelson42 I have tested the test binary that you provided me and also with the https://tmp.kiwix.org/ci/dev_preview/fix_android_compilation, and the application is not crashing with these binary on the arm architecture. I can read the zim file without crashing. Also, the testZim is now starts showing on the library screen so the crash scenario is fixed for the arm architecture.

Screenshot from 2024-06-05 10-48-41
Screenshot from 2024-06-05 10-48-29

@mgautierfr
Copy link
Member Author

Perfect. I'm merging.

@mgautierfr mgautierfr merged commit 9f9c03a into main Jun 5, 2024
41 checks passed
@mgautierfr mgautierfr deleted the fix_android_compilation branch June 5, 2024 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libm.so] __gnu_Unwind_Resume
3 participants