Skip to content

Use 16 KB ELF alignment for shared native libraries #7897

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

Merged
merged 1 commit into from
Sep 13, 2024

Conversation

mannodermaus
Copy link
Contributor

Starting from the upcoming Android 15, the possibility for devices configured with a memory page size of 16 KB (rather than the default 4 KB) becomes available to OEMs. This has an impact on how native code must be packed into Android applications in order to prevent crashes at runtime when unaligned code is being loaded on these devices (ref #7894).

This PR applies the suggested migration steps for 16 KB ELF packaging to the output of realm-library. As I did not want to upgrade the entire stack to AGP 8.3+ and NDK 27+, it follows the "legacy path" that yields the same results: After building the native libraries with these flags, calls to Realm.init() no longer cause an immediate crash on devices/emulators configured with 16 KB page size.

Full disclaimer: This change also applies to the objectServer binaries, which we aren't using for our use case. I don't know if there are any ramifications of 16 KB page size for those binaries.

Copy link

cla-bot bot commented Jul 30, 2024

Realm welcomes all contributions! The only requirement we have is that, like many other projects, we need to have a Contributor License Agreement (CLA) in place before we can accept any external code. Our own CLA is a modified version of the Apache Software Foundation’s CLA. Our records show that CLA has not been signed by @mannodermaus. Please submit your CLA electronically using our Google form so we can accept your submissions. After signing the CLA you can recheck this PR with a @cla-bot check comment. The GitHub usernames you file there will need to match that of your Pull Requests. If you have any questions or cannot file the CLA electronically, make a comment here and we will be happy to help you out.

@mannodermaus
Copy link
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla: yes label Jul 30, 2024
Copy link

cla-bot bot commented Jul 30, 2024

The cla-bot has been summoned, and re-checked this pull request!

Copy link

@swankjesse swankjesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good fix.

@mannodermaus
Copy link
Contributor Author

@swankjesse Thanks for the review! I added a changelog entry as well, but the PR may require another review pass because of that. If we don't foresee any issues with objectServer, then I suppose this would be safe to go in after.

@nhachicha
Copy link
Collaborator

Thanks @mannodermaus @swankjesse for the PR and review, I've introduced the same change in Kotlin in https://github.com/realm/realm-kotlin/pull/1788/files#diff-20de1441ff4c65066df79aa3e4da6a14c3705f68f5327ae1113591e135a6b3c0
I'll aim to do a release this week ~

@nhachicha nhachicha merged commit a69ad2f into realm:main Sep 13, 2024
1 check passed
@nhachicha
Copy link
Collaborator

@mannodermaus I just pushed 10.19.0 into maven central could you please give it a try?
Cheers.

@mannodermaus
Copy link
Contributor Author

I can confirm that using 10.19.0 loads the Realm database correctly on a device with 16KB page size. Thank you!

@mannodermaus mannodermaus deleted the 16kb-elf-packaging branch September 17, 2024 02:52
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants