| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromium_linker_test_apk; | 5 package org.chromium.chromium_linker_test_apk; |
| 6 | 6 |
| 7 import org.chromium.base.Log; | 7 import org.chromium.base.Log; |
| 8 import org.chromium.base.annotations.JNINamespace; | 8 import org.chromium.base.annotations.JNINamespace; |
| 9 import org.chromium.base.library_loader.Linker; | 9 import org.chromium.base.library_loader.Linker; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * A class that is only used in linker test APK to perform runtime checks | 12 * A class that is only used in linker test APK to perform runtime checks |
| 13 * in the current process. | 13 * in the current process. |
| 14 */ | 14 */ |
| 15 @JNINamespace("content") | 15 @JNINamespace("content") |
| 16 public class LinkerTests implements Linker.TestRunner { | 16 public class LinkerTests implements Linker.TestRunner { |
| 17 private static final String TAG = "cr.linker_test"; | 17 private static final String TAG = "cr.linker_test"; |
| 18 | 18 |
| 19 public LinkerTests() {} | 19 public LinkerTests() {} |
| 20 | 20 |
| 21 @Override | 21 @Override |
| 22 public boolean runChecks(int memoryDeviceConfig, | 22 public boolean runChecks(int memoryDeviceConfig, |
| 23 boolean isBrowserProcess) { | 23 boolean isBrowserProcess) { |
| 24 boolean checkSharedRelro; | 24 boolean checkSharedRelro; |
| 25 if (isBrowserProcess) { | 25 if (isBrowserProcess) { |
| 26 Linker linker = Linker.getInstance(); | 26 Linker linker = Linker.getInstance(); |
| 27 int linkerImplementation = linker.getLinkerImplementationForTesting(
); | 27 int linkerImplementation = linker.getImplementationForTesting(); |
| 28 | 28 |
| 29 if (linkerImplementation == Linker.LINKER_IMPLEMENTATION_LEGACY) { | 29 if (linkerImplementation == Linker.LINKER_IMPLEMENTATION_LEGACY) { |
| 30 // LegacyLinker may share RELROs in the browser. | 30 // LegacyLinker may share RELROs in the browser. |
| 31 switch (Linker.BROWSER_SHARED_RELRO_CONFIG) { | 31 switch (Linker.BROWSER_SHARED_RELRO_CONFIG) { |
| 32 case Linker.BROWSER_SHARED_RELRO_CONFIG_NEVER: | 32 case Linker.BROWSER_SHARED_RELRO_CONFIG_NEVER: |
| 33 checkSharedRelro = false; | 33 checkSharedRelro = false; |
| 34 break; | 34 break; |
| 35 case Linker.BROWSER_SHARED_RELRO_CONFIG_LOW_RAM_ONLY: | 35 case Linker.BROWSER_SHARED_RELRO_CONFIG_LOW_RAM_ONLY: |
| 36 // A shared RELRO should only be used on low-end devices
. | 36 // A shared RELRO should only be used on low-end devices
. |
| 37 checkSharedRelro = | 37 checkSharedRelro = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 // Check that there are shared RELRO sections in the current process, | 70 // Check that there are shared RELRO sections in the current process, |
| 71 // and that they are properly mapped read-only. Returns true on success. | 71 // and that they are properly mapped read-only. Returns true on success. |
| 72 private static native boolean nativeCheckForSharedRelros(boolean isBrowserPr
ocess); | 72 private static native boolean nativeCheckForSharedRelros(boolean isBrowserPr
ocess); |
| 73 | 73 |
| 74 // Check that there are no shared RELRO sections in the current process, | 74 // Check that there are no shared RELRO sections in the current process, |
| 75 // return true on success. | 75 // return true on success. |
| 76 private static native boolean nativeCheckForNoSharedRelros(boolean isBrowser
Process); | 76 private static native boolean nativeCheckForNoSharedRelros(boolean isBrowser
Process); |
| 77 } | 77 } |
| OLD | NEW |