Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2434)

Unified Diff: base/android/linker/linker_jni.cc

Issue 706203003: Update from https://crrev.com/303153 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/android/library_loader/library_load_from_apk_status_codes.h ('k') | base/file_version_info_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/android/linker/linker_jni.cc
diff --git a/base/android/linker/linker_jni.cc b/base/android/linker/linker_jni.cc
index 2b5a07dd203947dd52c33e9aff82ccf20053c2c2..b3ed651962fc5eb2321b3fa51f60fad2d7e33b73 100644
--- a/base/android/linker/linker_jni.cc
+++ b/base/android/linker/linker_jni.cc
@@ -386,6 +386,17 @@ jboolean LoadLibraryInZipFile(JNIEnv* env,
static_cast<size_t>(load_address), lib_info_obj, opener);
}
+// Enable the fallback due to lack of support for mapping the APK file with
+// executable permission in the crazy linker.
+//
+// |env| is the current JNI environment handle and is ignored here.
+// |clazz| is the static class handle for org.chromium.base.Linker,
+// and is ignored here.
+void EnableNoMapExecSupportFallback(JNIEnv* env, jclass clazz) {
+ crazy_context_t* context = GetCrazyContext();
+ crazy_context_set_no_map_exec_support_fallback_enabled(context, true);
+}
+
// Class holding the Java class and method ID for the Java side Linker
// postCallbackOnMainThread method.
struct JavaCallbackBindings_class {
@@ -598,15 +609,14 @@ jstring GetLibraryFilePathInZipFile(JNIEnv* env,
return env->NewStringUTF(buffer);
}
-// Check whether the device supports loading a library directly from the APK
-// file.
+// Check whether the device supports mapping the APK file with executable
+// permission.
//
// |env| is the current JNI environment handle.
// |clazz| is the static class handle which is not used here.
// |apkfile_name| is the filename of the APK.
// Returns true if supported.
-jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz,
- jstring apkfile_name) {
+jboolean CheckMapExecSupport(JNIEnv* env, jclass clazz, jstring apkfile_name) {
String apkfile_name_str(env, apkfile_name);
const char* apkfile_name_c_str = apkfile_name_str.c_str();
@@ -635,27 +645,28 @@ jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz,
return status;
}
-// Check whether a library is page aligned in the APK file.
+// Check whether a library is page aligned and uncompressed in the APK file.
//
// |env| is the current JNI environment handle.
// |clazz| is the static class handle which is not used here.
// |apkfile_name| is the filename of the APK.
// |library_name| is the library base name.
-// Returns true if page aligned.
-jboolean CheckLibraryAlignedInApk(JNIEnv* env, jclass clazz,
- jstring apkfile_name, jstring library_name) {
+// Returns true if page aligned and uncompressed.
+jboolean CheckLibraryIsMappableInApk(JNIEnv* env, jclass clazz,
+ jstring apkfile_name,
+ jstring library_name) {
String apkfile_name_str(env, apkfile_name);
const char* apkfile_name_c_str = apkfile_name_str.c_str();
String library_name_str(env, library_name);
const char* library_name_c_str = library_name_str.c_str();
- LOG_INFO("%s: Checking if %s is page-aligned in %s\n", __FUNCTION__,
- library_name_c_str, apkfile_name_c_str);
- jboolean aligned = crazy_linker_check_library_aligned_in_zip_file(
+ LOG_INFO("%s: Checking if %s is page-aligned and uncompressed in %s\n",
+ __FUNCTION__, library_name_c_str, apkfile_name_c_str);
+ jboolean mappable = crazy_linker_check_library_is_mappable_in_zip_file(
apkfile_name_c_str, library_name_c_str) == CRAZY_STATUS_SUCCESS;
LOG_INFO("%s: %s\n", __FUNCTION__, aligned ? "Aligned" : "NOT aligned");
- return aligned;
+ return mappable;
}
const JNINativeMethod kNativeMethods[] = {
@@ -676,6 +687,11 @@ const JNINativeMethod kNativeMethods[] = {
")"
"Z",
reinterpret_cast<void*>(&LoadLibraryInZipFile)},
+ {"nativeEnableNoMapExecSupportFallback",
+ "("
+ ")"
+ "V",
+ reinterpret_cast<void*>(&EnableNoMapExecSupportFallback)},
{"nativeRunCallbackOnUiThread",
"("
"J"
@@ -714,19 +730,19 @@ const JNINativeMethod kNativeMethods[] = {
")"
"Ljava/lang/String;",
reinterpret_cast<void*>(&GetLibraryFilePathInZipFile)},
- {"nativeCheckLibraryLoadFromApkSupport",
+ {"nativeCheckMapExecSupport",
"("
"Ljava/lang/String;"
")"
"Z",
- reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)},
- {"nativeCheckLibraryAlignedInApk",
+ reinterpret_cast<void*>(&CheckMapExecSupport)},
+ {"nativeCheckLibraryIsMappableInApk",
"("
"Ljava/lang/String;"
"Ljava/lang/String;"
")"
"Z",
- reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, };
+ reinterpret_cast<void*>(&CheckLibraryIsMappableInApk)}, };
} // namespace
« no previous file with comments | « base/android/library_loader/library_load_from_apk_status_codes.h ('k') | base/file_version_info_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698