Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 package org.chromium.base.library_loader; | 5 package org.chromium.base.library_loader; |
| 6 | 6 |
| 7 import android.os.Build; | 7 import android.os.Build; |
| 8 import android.os.Bundle; | 8 import android.os.Bundle; |
| 9 import android.os.Parcel; | 9 import android.os.Parcel; |
| 10 import android.os.ParcelFileDescriptor; | 10 import android.os.ParcelFileDescriptor; |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 } | 503 } |
| 504 | 504 |
| 505 /** | 505 /** |
| 506 * Determine whether a library is the linker library. Also deal with the | 506 * Determine whether a library is the linker library. Also deal with the |
| 507 * component build that adds a .cr suffix to the name. | 507 * component build that adds a .cr suffix to the name. |
| 508 * | 508 * |
| 509 * @param library the name of the library. | 509 * @param library the name of the library. |
| 510 * @return true is the library is the Linker's own JNI library. | 510 * @return true is the library is the Linker's own JNI library. |
| 511 */ | 511 */ |
| 512 public boolean isChromiumLinkerLibrary(String library) { | 512 public boolean isChromiumLinkerLibrary(String library) { |
| 513 return library.equals(LINKER_JNI_LIBRARY) || library.equals(LINKER_JNI_L IBRARY + ".cr"); | 513 return library.equals(LINKER_JNI_LIBRARY) || library.equals(LINKER_JNI_L IBRARY + ".cr"); |
|
Torne
2016/10/24 12:07:03
Seems like we should also remove the .cr case here
michaelbai
2016/10/25 22:21:53
Done.
| |
| 514 } | 514 } |
| 515 | 515 |
| 516 /** | 516 /** |
| 517 * Load the Linker JNI library. Throws UnsatisfiedLinkError on error. | 517 * Load the Linker JNI library. Throws UnsatisfiedLinkError on error. |
| 518 * In a component build, the suffix ".cr" is added to each library name, so | |
| 519 * if the initial load fails we retry with a suffix. | |
| 520 */ | 518 */ |
| 521 protected static void loadLinkerJniLibrary() { | 519 protected static void loadLinkerJniLibrary() { |
| 522 String libName = "lib" + LINKER_JNI_LIBRARY + ".so"; | 520 String libName = "lib" + LINKER_JNI_LIBRARY + ".so"; |
| 523 if (DEBUG) { | 521 if (DEBUG) { |
| 524 Log.i(TAG, "Loading " + libName); | 522 Log.i(TAG, "Loading " + libName); |
| 525 } | 523 } |
| 526 try { | 524 System.loadLibrary(LINKER_JNI_LIBRARY); |
| 527 System.loadLibrary(LINKER_JNI_LIBRARY); | |
| 528 } catch (UnsatisfiedLinkError e) { | |
| 529 Log.w(TAG, "Couldn't load " + libName + ", trying " + libName + ".cr "); | |
| 530 System.loadLibrary(LINKER_JNI_LIBRARY + ".cr"); | |
| 531 } | |
| 532 } | 525 } |
| 533 | 526 |
| 534 /** | 527 /** |
| 535 * Obtain a random base load address at which to place loaded libraries. | 528 * Obtain a random base load address at which to place loaded libraries. |
| 536 * | 529 * |
| 537 * @return new base load address | 530 * @return new base load address |
| 538 */ | 531 */ |
| 539 protected long getRandomBaseLoadAddress() { | 532 protected long getRandomBaseLoadAddress() { |
| 540 // nativeGetRandomBaseLoadAddress() returns an address at which it has p reviously | 533 // nativeGetRandomBaseLoadAddress() returns an address at which it has p reviously |
| 541 // successfully mapped an area larger than the largest library we expect to load, | 534 // successfully mapped an area larger than the largest library we expect to load, |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 * Return a random address that should be free to be mapped with the given s ize. | 817 * Return a random address that should be free to be mapped with the given s ize. |
| 825 * Maps an area large enough for the largest library we might attempt to loa d, | 818 * Maps an area large enough for the largest library we might attempt to loa d, |
| 826 * and if successful then unmaps it and returns the address of the area allo cated | 819 * and if successful then unmaps it and returns the address of the area allo cated |
| 827 * by the system (with ASLR). The idea is that this area should remain free of | 820 * by the system (with ASLR). The idea is that this area should remain free of |
| 828 * other mappings until we map our library into it. | 821 * other mappings until we map our library into it. |
| 829 * | 822 * |
| 830 * @return address to pass to future mmap, or 0 on error. | 823 * @return address to pass to future mmap, or 0 on error. |
| 831 */ | 824 */ |
| 832 private static native long nativeGetRandomBaseLoadAddress(); | 825 private static native long nativeGetRandomBaseLoadAddress(); |
| 833 } | 826 } |
| OLD | NEW |