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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 months 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/base.gyp » ('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 a545c528ed336e44953138c9a51f8ad5647a1bf4..30aced19769acc594e2953c6933be08f2d0d7877 100644
--- a/base/android/linker/linker_jni.cc
+++ b/base/android/linker/linker_jni.cc
@@ -584,7 +584,7 @@ jlong GetRandomBaseLoadAddress(JNIEnv* env, jclass clazz, jlong bytes) {
// |apkfile_name| is the filename of the APK.
// Returns true if supported.
jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz,
- jstring apkfile_name) {
+ jstring apkfile_name) {
String apkfile_name_str(env, apkfile_name);
const char* apkfile_name_c_str = apkfile_name_str.c_str();
@@ -613,6 +613,29 @@ jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz,
return status;
}
+// Check whether a library is page aligned 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) {
+ 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(
+ apkfile_name_c_str, library_name_c_str) == CRAZY_STATUS_SUCCESS;
+ LOG_INFO("%s: %s\n", __FUNCTION__, aligned ? "Aligned" : "NOT aligned");
+
+ return aligned;
+}
+
const JNINativeMethod kNativeMethods[] = {
{"nativeLoadLibrary",
"("
@@ -668,7 +691,14 @@ const JNINativeMethod kNativeMethods[] = {
"Ljava/lang/String;"
")"
"Z",
- reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)}, };
+ reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)},
+ {"nativeCheckLibraryAlignedInApk",
+ "("
+ "Ljava/lang/String;"
+ "Ljava/lang/String;"
+ ")"
+ "Z",
+ reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, };
} // namespace
« no previous file with comments | « base/android/library_loader/library_load_from_apk_status_codes.h ('k') | base/base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698