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

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: Add new 'content_linker_unittests_apk' target + ensure ashmem regions are forced read-only 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..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);
}

Powered by Google App Engine
This is Rietveld 408576698