summaryrefslogtreecommitdiff
path: root/native/webview/loader/loader.cpp
diff options
context:
space:
mode:
authorTorne (Richard Coles) <torne@google.com>2019-04-01 15:11:00 -0400
committerRichard Coles <torne@google.com>2019-04-04 14:41:03 +0000
commitd2f37cc575920909e0e5712dbcf97e02f5e522c0 (patch)
tree54d356240aae9e99b03ca8dc511e0e375691d60e /native/webview/loader/loader.cpp
parentdd07ae579c291a2b6ffe09bd576fd908eb9e5ddd (diff)
Allow the WebView native library to have dependencies.
The WebView native library has so far only depended on native libraries that were already loaded by the zygote, and has only shipped a single .so file in its APK. Splitting the code into multiple libraries worked, but only the top-level library would have its RELRO section shared, causing a memory regression. To avoid this regression if we do decide to split up the native code in future, load the native library using the new RESERVED_ADDRESS_RECURSIVE flag in the linker, which means that any depended-upon libraries will also be loaded into the reserved address region and will have their RELRO sections saved and reused. Fixes: 128623590 Test: tested manually with modified WebView Change-Id: I19ee3ff971e8dcd1c683f94af304abf918860a10
Diffstat (limited to 'native/webview/loader/loader.cpp')
-rw-r--r--native/webview/loader/loader.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/native/webview/loader/loader.cpp b/native/webview/loader/loader.cpp
index 7f71f6312f00..1265763d47d3 100644
--- a/native/webview/loader/loader.cpp
+++ b/native/webview/loader/loader.cpp
@@ -93,7 +93,8 @@ jboolean DoCreateRelroFile(JNIEnv* env, const char* lib, const char* relro,
}
android_dlextinfo extinfo;
extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS | ANDROID_DLEXT_WRITE_RELRO |
- ANDROID_DLEXT_USE_NAMESPACE;
+ ANDROID_DLEXT_USE_NAMESPACE |
+ ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE;
extinfo.reserved_addr = gReservedAddress;
extinfo.reserved_size = gReservedSize;
extinfo.relro_fd = tmp_fd;
@@ -131,7 +132,8 @@ jint DoLoadWithRelroFile(JNIEnv* env, const char* lib, const char* relro,
}
android_dlextinfo extinfo;
extinfo.flags = ANDROID_DLEXT_RESERVED_ADDRESS | ANDROID_DLEXT_USE_RELRO |
- ANDROID_DLEXT_USE_NAMESPACE;
+ ANDROID_DLEXT_USE_NAMESPACE |
+ ANDROID_DLEXT_RESERVED_ADDRESS_RECURSIVE;
extinfo.reserved_addr = gReservedAddress;
extinfo.reserved_size = gReservedSize;
extinfo.relro_fd = relro_fd;