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

Side by Side Diff: base/android/linker/linker_jni.cc

Issue 693943003: Update from https://crrev.com/302630 (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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is the Android-specific Chromium linker, a tiny shared library 5 // This is the Android-specific Chromium linker, a tiny shared library
6 // implementing a custom dynamic linker that can be used to load the 6 // implementing a custom dynamic linker that can be used to load the
7 // real Chromium libraries (e.g. libcontentshell.so). 7 // real Chromium libraries (e.g. libcontentshell.so).
8 8
9 // The main point of this linker is to be able to share the RELRO 9 // The main point of this linker is to be able to share the RELRO
10 // section of libcontentshell.so (or equivalent) between the browser and 10 // section of libcontentshell.so (or equivalent) between the browser and
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 mmap(NULL, bytes, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); 569 mmap(NULL, bytes, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
570 if (address == MAP_FAILED) { 570 if (address == MAP_FAILED) {
571 LOG_INFO("%s: Random base load address not determinable\n", __FUNCTION__); 571 LOG_INFO("%s: Random base load address not determinable\n", __FUNCTION__);
572 return 0; 572 return 0;
573 } 573 }
574 munmap(address, bytes); 574 munmap(address, bytes);
575 LOG_INFO("%s: Random base load address is %p\n", __FUNCTION__, address); 575 LOG_INFO("%s: Random base load address is %p\n", __FUNCTION__, address);
576 return static_cast<jlong>(reinterpret_cast<uintptr_t>(address)); 576 return static_cast<jlong>(reinterpret_cast<uintptr_t>(address));
577 } 577 }
578 578
579 // Get the full path of a library in the zip file
580 // (lib/<abi>/crazy.<lib_name>).
581 //
582 // |env| is the current JNI environment handle.
583 // |clazz| is the static class handle which is not used here.
584 // |lib_name| is the library base name.
585 // Returns the full path (or empty string on failure).
586 jstring GetLibraryFilePathInZipFile(JNIEnv* env,
587 jclass clazz,
588 jstring lib_name) {
589 String lib_name_str(env, lib_name);
590 const char* lib_name_c_str = lib_name_str.c_str();
591 char buffer[kMaxFilePathLengthInZip + 1];
592 if (crazy_library_file_path_in_zip_file(
593 lib_name_c_str, buffer, sizeof(buffer)) == CRAZY_STATUS_FAILURE) {
594 LOG_ERROR("%s: Failed to get full filename for library '%s'",
595 __FUNCTION__, lib_name_c_str);
596 buffer[0] = '\0';
597 }
598 return env->NewStringUTF(buffer);
599 }
600
579 // Check whether the device supports loading a library directly from the APK 601 // Check whether the device supports loading a library directly from the APK
580 // file. 602 // file.
581 // 603 //
582 // |env| is the current JNI environment handle. 604 // |env| is the current JNI environment handle.
583 // |clazz| is the static class handle which is not used here. 605 // |clazz| is the static class handle which is not used here.
584 // |apkfile_name| is the filename of the APK. 606 // |apkfile_name| is the filename of the APK.
585 // Returns true if supported. 607 // Returns true if supported.
586 jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz, 608 jboolean CheckLibraryLoadFromApkSupport(JNIEnv* env, jclass clazz,
587 jstring apkfile_name) { 609 jstring apkfile_name) {
588 String apkfile_name_str(env, apkfile_name); 610 String apkfile_name_str(env, apkfile_name);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 "(" 701 "("
680 ")" 702 ")"
681 "Z", 703 "Z",
682 reinterpret_cast<void*>(&CanUseSharedRelro)}, 704 reinterpret_cast<void*>(&CanUseSharedRelro)},
683 {"nativeGetRandomBaseLoadAddress", 705 {"nativeGetRandomBaseLoadAddress",
684 "(" 706 "("
685 "J" 707 "J"
686 ")" 708 ")"
687 "J", 709 "J",
688 reinterpret_cast<void*>(&GetRandomBaseLoadAddress)}, 710 reinterpret_cast<void*>(&GetRandomBaseLoadAddress)},
689 {"nativeCheckLibraryLoadFromApkSupport", 711 {"nativeGetLibraryFilePathInZipFile",
690 "(" 712 "("
691 "Ljava/lang/String;" 713 "Ljava/lang/String;"
692 ")" 714 ")"
693 "Z", 715 "Ljava/lang/String;",
694 reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)}, 716 reinterpret_cast<void*>(&GetLibraryFilePathInZipFile)},
695 {"nativeCheckLibraryAlignedInApk", 717 {"nativeCheckLibraryLoadFromApkSupport",
696 "(" 718 "("
697 "Ljava/lang/String;" 719 "Ljava/lang/String;"
698 "Ljava/lang/String;" 720 ")"
699 ")" 721 "Z",
700 "Z", 722 reinterpret_cast<void*>(&CheckLibraryLoadFromApkSupport)},
701 reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, }; 723 {"nativeCheckLibraryAlignedInApk",
724 "("
725 "Ljava/lang/String;"
726 "Ljava/lang/String;"
727 ")"
728 "Z",
729 reinterpret_cast<void*>(&CheckLibraryAlignedInApk)}, };
702 730
703 } // namespace 731 } // namespace
704 732
705 // JNI_OnLoad() hook called when the linker library is loaded through 733 // JNI_OnLoad() hook called when the linker library is loaded through
706 // the regular System.LoadLibrary) API. This shall save the Java VM 734 // the regular System.LoadLibrary) API. This shall save the Java VM
707 // handle and initialize LibInfo fields. 735 // handle and initialize LibInfo fields.
708 jint JNI_OnLoad(JavaVM* vm, void* reserved) { 736 jint JNI_OnLoad(JavaVM* vm, void* reserved) {
709 LOG_INFO("%s: Entering", __FUNCTION__); 737 LOG_INFO("%s: Entering", __FUNCTION__);
710 // Get new JNIEnv 738 // Get new JNIEnv
711 JNIEnv* env; 739 JNIEnv* env;
(...skipping 30 matching lines...) Expand all
742 crazy_context_t* context = GetCrazyContext(); 770 crazy_context_t* context = GetCrazyContext();
743 crazy_context_set_java_vm(context, vm, JNI_VERSION_1_4); 771 crazy_context_set_java_vm(context, vm, JNI_VERSION_1_4);
744 772
745 // Register the function that the crazy linker can call to post code 773 // Register the function that the crazy linker can call to post code
746 // for later execution. 774 // for later execution.
747 crazy_context_set_callback_poster(context, &PostForLaterExecution, NULL); 775 crazy_context_set_callback_poster(context, &PostForLaterExecution, NULL);
748 776
749 LOG_INFO("%s: Done", __FUNCTION__); 777 LOG_INFO("%s: Done", __FUNCTION__);
750 return JNI_VERSION_1_4; 778 return JNI_VERSION_1_4;
751 } 779 }
OLDNEW
« no previous file with comments | « base/android/javatests/src/org/chromium/base/LibraryLoaderHelperTest.java ('k') | base/bind_unittest.nc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698