Index: content/shell/android/linker_test_apk/src/org/chromium/content_linker_test_apk/LinkerTests.java |
diff --git a/content/shell/android/linker_test_apk/src/org/chromium/content_linker_test_apk/LinkerTests.java b/content/shell/android/linker_test_apk/src/org/chromium/content_linker_test_apk/LinkerTests.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8ce06ce24eb6ef7e80e79e284bdb262647884784 |
--- /dev/null |
+++ b/content/shell/android/linker_test_apk/src/org/chromium/content_linker_test_apk/LinkerTests.java |
@@ -0,0 +1,48 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.content_linker_test_apk; |
+ |
+import android.util.Log; |
+ |
+import org.chromium.base.JNINamespace; |
+import org.chromium.content.app.Linker; |
+ |
+// A class that is only used in linker test APK to perform runtime checks |
+// in the current process. |
+@JNINamespace("content") |
+public class LinkerTests implements Linker.TestRunner { |
+ private static final String TAG = "LinkerTests"; |
+ |
+ public LinkerTests() {} |
+ |
+ public boolean runChecks(int memoryDeviceConfig, |
+ boolean isBrowserProcess) { |
+ switch (memoryDeviceConfig) { |
+ case Linker.MEMORY_DEVICE_CONFIG_LOW: |
+ // On low-memory devices, shared RELROs are used in every process. |
+ return nativeCheckForSharedRelros(isBrowserProcess); |
+ |
+ case Linker.MEMORY_DEVICE_CONFIG_NORMAL: |
+ // On regular devices, only service processes use a shared RELRO section. |
+ if (isBrowserProcess) |
+ return nativeCheckForNoSharedRelros(isBrowserProcess); |
+ else |
+ return nativeCheckForSharedRelros(isBrowserProcess); |
+ |
+ default: |
+ Log.e(TAG, "Invalid memory device configuration: " + memoryDeviceConfig); |
+ return false; |
+ } |
+ } |
+ |
+ // Check that there are shared RELRO sections in the current process, |
+ // and that they are properly mapped read-only. Returns true on success. |
+ private static native boolean nativeCheckForSharedRelros(boolean isBrowserProcess); |
+ |
+ // Check that there are no shared RELRO sections in the current process, |
+ // return true on success. |
+ private static native boolean nativeCheckForNoSharedRelros(boolean isBrowserProcess); |
+ |
+} |