Chromium Code Reviews| Index: base/android/java/src/org/chromium/base/library_loader/Linker.java |
| diff --git a/base/android/java/src/org/chromium/base/library_loader/Linker.java b/base/android/java/src/org/chromium/base/library_loader/Linker.java |
| index c08005e3d1b4f4cbe5598dbe745f602ed8151d84..29fb1ac515ea4d1aff6e7fb61384b0f1fec17135 100644 |
| --- a/base/android/java/src/org/chromium/base/library_loader/Linker.java |
| +++ b/base/android/java/src/org/chromium/base/library_loader/Linker.java |
| @@ -700,33 +700,17 @@ public class Linker { |
| } |
| /** |
| - * Load a native shared library with the Chromium linker. |
| - * The shared library is uncompressed and page aligned inside the zipfile. |
| - * Note the crazy linker treats libraries and files as equivalent, |
| - * so you can only open one library in a given zip file. The library must |
| - * not be the Chromium linker library. |
| + * Load a native shared library with the Chromium linker. If the zip file |
| + * is not null, the shared library must be uncompressed and page aligned |
| + * inside the zipfile. Note the crazy linker treats libraries and files as |
| + * equivalent, so you can only open one library in a given zip file. The |
| + * library must not be the Chromium linker library. |
| * |
| - * @param zipfile The filename of the zipfile contain the library. |
| - * @param library The library's base name. |
| + * @param zipFilename The filename of the zip file containing the library (or null). |
| + * @param libFilename The filename of the library. |
| */ |
| - public static void loadLibraryInZipFile(String zipfile, String library) { |
| - loadLibraryMaybeInZipFile(zipfile, library); |
| - } |
| - |
| - /** |
| - * Load a native shared library with the Chromium linker. The library must |
| - * not be the Chromium linker library. |
| - * |
| - * @param library The library's base name. |
| - */ |
| - public static void loadLibrary(String library) { |
| - loadLibraryMaybeInZipFile(null, library); |
| - } |
| - |
| - private static void loadLibraryMaybeInZipFile( |
| - @Nullable String zipFile, String library) { |
| - if (DEBUG) Log.i(TAG, "loadLibrary: " + library); |
| - assert !isChromiumLinkerLibrary(library); |
|
rmcilroy
2014/10/29 17:20:44
Do you need to remove this assert or is it ok to a
petrcermak
2014/10/30 19:55:07
The problem here is that libFilePath is "libchromi
|
| + public static void loadLibrary(@Nullable String zipFilename, String libFilename) { |
|
rmcilroy
2014/10/29 17:20:44
zipFilePath and libFilePath
petrcermak
2014/10/30 19:55:07
Done.
|
| + if (DEBUG) Log.i(TAG, "loadLibrary: " + zipFilename + ", " + libFilename); |
| synchronized (Linker.class) { |
| ensureInitializedLocked(); |
| @@ -737,12 +721,10 @@ public class Linker { |
| // that wrap all calls to loadLibrary() in the library loader. |
| assert sPrepareLibraryLoadCalled; |
| - String libName = System.mapLibraryName(library); |
| - |
| if (sLoadedLibraries == null) sLoadedLibraries = new HashMap<String, LibInfo>(); |
| - if (sLoadedLibraries.containsKey(libName)) { |
| - if (DEBUG) Log.i(TAG, "Not loading " + libName + " twice"); |
| + if (sLoadedLibraries.containsKey(libFilename)) { |
| + if (DEBUG) Log.i(TAG, "Not loading " + libFilename + " twice"); |
| return; |
| } |
| @@ -753,18 +735,18 @@ public class Linker { |
| loadAddress = sCurrentLoadAddress; |
| } |
| - String sharedRelRoName = libName; |
| - if (zipFile != null) { |
| - if (!nativeLoadLibraryInZipFile(zipFile, libName, loadAddress, libInfo)) { |
| - String errorMessage = "Unable to load library: " + libName + |
| - ", in: " + zipFile; |
| + String sharedRelRoName = libFilename; |
| + if (zipFilename != null) { |
| + if (!nativeLoadLibraryInZipFile(zipFilename, libFilename, loadAddress, libInfo)) { |
| + String errorMessage = "Unable to load library: " + libFilename + |
| + ", in: " + zipFilename; |
| Log.e(TAG, errorMessage); |
| throw new UnsatisfiedLinkError(errorMessage); |
| } |
| - sharedRelRoName = zipFile; |
| + sharedRelRoName = zipFilename; |
| } else { |
| - if (!nativeLoadLibrary(libName, loadAddress, libInfo)) { |
| - String errorMessage = "Unable to load library: " + libName; |
| + if (!nativeLoadLibrary(libFilename, loadAddress, libInfo)) { |
| + String errorMessage = "Unable to load library: " + libFilename; |
| Log.e(TAG, errorMessage); |
| throw new UnsatisfiedLinkError(errorMessage); |
| } |
| @@ -781,7 +763,7 @@ public class Linker { |
| Locale.US, |
| "%s_LIBRARY_ADDRESS: %s %x", |
| sInBrowserProcess ? "BROWSER" : "RENDERER", |
| - libName, |
| + libFilename, |
| libInfo.mLoadAddress)); |
| } |
| @@ -789,7 +771,7 @@ public class Linker { |
| // Create a new shared RELRO section at the 'current' fixed load address. |
| if (!nativeCreateSharedRelro(sharedRelRoName, sCurrentLoadAddress, libInfo)) { |
| Log.w(TAG, String.format(Locale.US, |
| - "Could not create shared RELRO for %s at %x", libName, |
| + "Could not create shared RELRO for %s at %x", libFilename, |
| sCurrentLoadAddress)); |
| } else { |
| if (DEBUG) Log.i(TAG, |
| @@ -824,6 +806,16 @@ public class Linker { |
| } |
| /** |
| + * Get the full library filename in zip file (lib/<abi>/crazy.<lib_name>). |
| + * |
| + * @param library The library's base name. |
| + * @return the library filename (or empty string on failure). |
| + */ |
| + public static String getLibraryFilenameInZipFile(String library) { |
|
rmcilroy
2014/10/29 17:20:44
getLibraryFilePathInZipFile (and same for native)
petrcermak
2014/10/30 19:55:07
Done (all the way down to crazy_linker_library_lis
|
| + return nativeGetLibraryFilenameInZipFile(library); |
| + } |
| + |
| + /** |
| * Check whether the device supports loading a library directly from the APK file. |
| * |
| * @param apkFile Filename of the APK. |
| @@ -959,6 +951,15 @@ public class Linker { |
| private static native long nativeGetRandomBaseLoadAddress(long sizeBytes); |
| /** |
| + * Native method used to get the full library filename in zip file |
| + * (lib/<abi>/crazy.<lib_name>). |
| + * |
| + * @param library The library's base name. |
| + * @return the library filename (or empty string on failure). |
| + */ |
| + private static native String nativeGetLibraryFilenameInZipFile(String library); |
| + |
| + /** |
| * Native method which checks whether the device supports loading a library |
| * directly from the APK file. |
| * |