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

Unified Diff: content/public/android/java/src/org/chromium/content/app/LibraryLoader.java

Issue 23717023: Android: Add chrome-specific dynamic linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address later issues. Created 7 years, 3 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
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..b75803eb46af2ea8e07d8e4e62662e65bb0d7091 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());
}
}
@@ -108,10 +116,14 @@ public class LibraryLoader {
try {
if (!sLoaded) {
assert !sInitialized;
- for (String sLibrary : NativeLibraries.libraries) {
- Log.i(TAG, "loading: " + sLibrary);
- System.loadLibrary(sLibrary);
- Log.i(TAG, "loaded: " + sLibrary);
+ for (String library : NativeLibraries.libraries) {
+ Log.i(TAG, "Loading: " + library);
+ if (useCrazyLinker()) {
+ Linker.loadLibrary(library);
+ } else if (!library.equals("crazy_linker")) {
+ System.loadLibrary(library);
+ }
+ Log.i(TAG, "Loaded: " + library);
}
sLoaded = true;
}
@@ -138,6 +150,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 +163,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);
}

Powered by Google App Engine
This is Rietveld 408576698