OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.base.library_loader; | 5 package org.chromium.base.library_loader; |
6 | 6 |
7 import android.os.Build; | 7 import android.os.Build; |
8 import android.os.Bundle; | 8 import android.os.Bundle; |
9 import android.os.Parcel; | 9 import android.os.Parcel; |
10 import android.os.ParcelFileDescriptor; | 10 import android.os.ParcelFileDescriptor; |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 protected static final boolean DEBUG = false; | 188 protected static final boolean DEBUG = false; |
189 | 189 |
190 // Used to pass the shared RELRO Bundle through Binder. | 190 // Used to pass the shared RELRO Bundle through Binder. |
191 public static final String EXTRA_LINKER_SHARED_RELROS = | 191 public static final String EXTRA_LINKER_SHARED_RELROS = |
192 "org.chromium.base.android.linker.shared_relros"; | 192 "org.chromium.base.android.linker.shared_relros"; |
193 | 193 |
194 // Guards all access to the linker. | 194 // Guards all access to the linker. |
195 protected final Object mLock = new Object(); | 195 protected final Object mLock = new Object(); |
196 | 196 |
197 // The name of a class that implements TestRunner. | 197 // The name of a class that implements TestRunner. |
198 private String mTestRunnerClassName = null; | 198 private String mTestRunnerClassName; |
199 | 199 |
200 // Size of reserved Breakpad guard region. Should match the value of | 200 // Size of reserved Breakpad guard region. Should match the value of |
201 // kBreakpadGuardRegionBytes on the JNI side. Used when computing the load | 201 // kBreakpadGuardRegionBytes on the JNI side. Used when computing the load |
202 // addresses of multiple loaded libraries. Set to 0 to disable the guard. | 202 // addresses of multiple loaded libraries. Set to 0 to disable the guard. |
203 protected static final int BREAKPAD_GUARD_REGION_BYTES = 16 * 1024 * 1024; | 203 protected static final int BREAKPAD_GUARD_REGION_BYTES = 16 * 1024 * 1024; |
204 | 204 |
205 // Size of the area requested when using ASLR to obtain a random load addres
s. | 205 // Size of the area requested when using ASLR to obtain a random load addres
s. |
206 // Should match the value of kAddressSpaceReservationSize on the JNI side. | 206 // Should match the value of kAddressSpaceReservationSize on the JNI side. |
207 // Used when computing the load addresses of multiple loaded libraries to | 207 // Used when computing the load addresses of multiple loaded libraries to |
208 // ensure that we don't try to load outside the area originally requested. | 208 // ensure that we don't try to load outside the area originally requested. |
209 protected static final int ADDRESS_SPACE_RESERVATION = 192 * 1024 * 1024; | 209 protected static final int ADDRESS_SPACE_RESERVATION = 192 * 1024 * 1024; |
210 | 210 |
211 // Constants used to indicate a given Linker implementation, for testing. | 211 // Constants used to indicate a given Linker implementation, for testing. |
212 // LEGACY -> Always uses the LegacyLinker implementation. | 212 // LEGACY -> Always uses the LegacyLinker implementation. |
213 // MODERN -> Always uses the ModernLinker implementation. | 213 // MODERN -> Always uses the ModernLinker implementation. |
214 // NOTE: These names are known and expected by the Linker test scripts. | 214 // NOTE: These names are known and expected by the Linker test scripts. |
215 public static final int LINKER_IMPLEMENTATION_LEGACY = 1; | 215 public static final int LINKER_IMPLEMENTATION_LEGACY = 1; |
216 public static final int LINKER_IMPLEMENTATION_MODERN = 2; | 216 public static final int LINKER_IMPLEMENTATION_MODERN = 2; |
217 | 217 |
218 // Singleton. | 218 // Singleton. |
219 private static Linker sSingleton = null; | 219 private static Linker sSingleton; |
220 private static Object sSingletonLock = new Object(); | 220 private static Object sSingletonLock = new Object(); |
221 | 221 |
222 // Protected singleton constructor. | 222 // Protected singleton constructor. |
223 protected Linker() { } | 223 protected Linker() { } |
224 | 224 |
225 /** | 225 /** |
226 * Get singleton instance. Returns either a LegacyLinker or a ModernLinker. | 226 * Get singleton instance. Returns either a LegacyLinker or a ModernLinker. |
227 * | 227 * |
228 * Returns a ModernLinker if running on Android M or later, otherwise return
s | 228 * Returns a ModernLinker if running on Android M or later, otherwise return
s |
229 * a LegacyLinker. | 229 * a LegacyLinker. |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 * Return a random address that should be free to be mapped with the given s
ize. | 816 * Return a random address that should be free to be mapped with the given s
ize. |
817 * Maps an area large enough for the largest library we might attempt to loa
d, | 817 * Maps an area large enough for the largest library we might attempt to loa
d, |
818 * and if successful then unmaps it and returns the address of the area allo
cated | 818 * and if successful then unmaps it and returns the address of the area allo
cated |
819 * by the system (with ASLR). The idea is that this area should remain free
of | 819 * by the system (with ASLR). The idea is that this area should remain free
of |
820 * other mappings until we map our library into it. | 820 * other mappings until we map our library into it. |
821 * | 821 * |
822 * @return address to pass to future mmap, or 0 on error. | 822 * @return address to pass to future mmap, or 0 on error. |
823 */ | 823 */ |
824 private static native long nativeGetRandomBaseLoadAddress(); | 824 private static native long nativeGetRandomBaseLoadAddress(); |
825 } | 825 } |
OLD | NEW |