Skip to content

Commit a69ad2f

Browse files
authored
Use 16 KB ELF alignment for shared native libraries (#7897)
https://developer.android.com/guide/practices/page-sizes
1 parent e564a45 commit a69ad2f

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* None.
88

99
### Fixed
10-
* None.
10+
* Use 16 KB ELF packaging for native artifacts produced by `realm-library`, allowing them to be loaded on devices with 16 KB memory page sizes. (Issue [#7894](https://github.com/realm/realm-java/issues/7894))
1111

1212
### Compatibility
1313
* File format: Generates Realms with format v23. Unsynced Realms will be upgraded from Realm Java 2.0 and later. Synced Realms can only be read and upgraded if created with Realm Java v10.0.0-BETA.1.

realm/realm-library/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ android {
121121
// We did strip with cmake for release build.
122122
// Please, Gradle, you are not that smart! Pleas DO NOT strip debug symbols for debug build!
123123
doNotStrip "*/*/*.so"
124+
125+
// Use compressed shared libraries to support 16 KB ELF alignment
126+
jniLibs {
127+
useLegacyPackaging = true
128+
}
124129
}
125130

126131
lintOptions {

realm/realm-library/src/main/cpp/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ endif()
214214
add_library(realm-jni SHARED ${jni_SRC})
215215
target_link_libraries(realm-jni log android Realm::ObjectStore)
216216

217+
# Use 16 KB ELF alignment to support devices with page size greater than 4 KB
218+
target_link_options(realm-jni PRIVATE "-Wl,-z,max-page-size=16384")
219+
217220
# Strip the release so files and backup the unstripped versions
218221
if (buildTypeCap STREQUAL "Release")
219222
set(unstripped_SO_DIR

0 commit comments

Comments
 (0)