Index: content/public/android/java/src/org/chromium/content/app/LibraryLoader.java |
diff --git a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java b/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java |
index bf64b4feae831154cf77918067be6c29bd07b67b..7102a4309b7153cc95e9275d8030831f2b8875d5 100644 |
--- a/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java |
+++ b/content/public/android/java/src/org/chromium/content/app/LibraryLoader.java |
@@ -7,7 +7,9 @@ package org.chromium.content.app; |
import android.text.TextUtils; |
import android.util.Log; |
+import org.chromium.base.Linker; |
import org.chromium.base.JNINamespace; |
+import org.chromium.content.browser.ChildProcessLauncher; |
import org.chromium.content.common.CommandLine; |
import org.chromium.content.common.ProcessInitException; |
import org.chromium.content.common.ResultCodes; |
@@ -42,6 +44,10 @@ public class LibraryLoader { |
// library_loader_hooks.cc). |
private static boolean sInitialized = false; |
+ public static boolean useCrazyLinker() { |
+ return NativeLibraries.USE_CRAZY_LINKER; |
+ } |
+ |
// TODO(cjhopman): Remove this once it's unused. |
/** |
* Doesn't do anything. |
@@ -61,6 +67,8 @@ public class LibraryLoader { |
} |
loadAlreadyLocked(); |
initializeAlreadyLocked(CommandLine.getJavaSwitchesOrNull()); |
+ if (useCrazyLinker()) |
+ ChildProcessLauncher.setRelroBundle(Linker.getRelroBundle()); |
} |
} |
@@ -109,9 +117,11 @@ public class LibraryLoader { |
if (!sLoaded) { |
assert !sInitialized; |
for (String sLibrary : NativeLibraries.libraries) { |
- Log.i(TAG, "loading: " + sLibrary); |
- System.loadLibrary(sLibrary); |
- Log.i(TAG, "loaded: " + sLibrary); |
+ if (useCrazyLinker()) { |
+ Linker.loadLibrary(sLibrary); |
+ } else if (!sLibrary.equals("crazy_linker")) { |
+ System.loadLibrary(sLibrary); |
+ } |
} |
sLoaded = true; |
} |
@@ -138,6 +148,9 @@ public class LibraryLoader { |
sInitialized = true; |
CommandLine.enableNativeProxy(); |
TraceEvent.setEnabledToMatchNative(); |
+ // Record histogram for crazy linker. |
+ if (useCrazyLinker()) |
+ nativeRecordCrazyLinkerHistogram(Linker.loadAtFixedAddressFailed()); |
} |
// This is the only method that is registered during System.loadLibrary. We then call it |
@@ -148,4 +161,9 @@ public class LibraryLoader { |
// Return 0 on success, otherwise return the error code from |
// content/public/common/result_codes.h. |
private static native int nativeLibraryLoaded(String[] initCommandLine); |
+ |
+ // Method called to register if the crazy linker was able to load library at a fixed address. |
+ // This is called once the library loading is done and successful. |
+ private static native void nativeRecordCrazyLinkerHistogram( |
+ boolean loadedAtFixedAddressFailed); |
} |