| 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
|
|
|
|
|