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.Bundle; | 7 import android.os.Bundle; |
8 import android.os.SystemClock; | 8 import android.os.SystemClock; |
9 | 9 |
10 import org.chromium.base.Log; | 10 import org.chromium.base.Log; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 // The directory used to hold shared RELRO data files. Set up by prepareLibr
aryLoad(). | 64 // The directory used to hold shared RELRO data files. Set up by prepareLibr
aryLoad(). |
65 private String mDataDirectory = null; | 65 private String mDataDirectory = null; |
66 | 66 |
67 // Private singleton constructor, and singleton factory method. | 67 // Private singleton constructor, and singleton factory method. |
68 private ModernLinker() {} | 68 private ModernLinker() {} |
69 static Linker create() { | 69 static Linker create() { |
70 return new ModernLinker(); | 70 return new ModernLinker(); |
71 } | 71 } |
72 | 72 |
73 // Used internally to initialize the linker's data. Assume lock is held. | 73 // Used internally to initialize the linker's data. Assumes lock is held. |
74 private void ensureInitializedLocked() { | 74 private void ensureInitializedLocked() { |
75 assert Thread.holdsLock(mLock); | 75 assert Thread.holdsLock(mLock); |
76 assert NativeLibraries.sUseLinker; | 76 assert NativeLibraries.sUseLinker; |
77 | 77 |
78 // On first call, load libchromium_android_linker.so. | 78 // On first call, load libchromium_android_linker.so. Cannot be done in
the |
| 79 // constructor because the instance is constructed on the UI thread. |
79 if (!mInitialized) { | 80 if (!mInitialized) { |
80 loadLinkerJNILibrary(); | 81 loadLinkerJniLibrary(); |
81 mInitialized = true; | 82 mInitialized = true; |
82 } | 83 } |
83 } | 84 } |
84 | 85 |
85 /** | 86 /** |
86 * Call this method to determine if this chromium project must | |
87 * use this linker. If not, System.loadLibrary() should be used to load | |
88 * libraries instead. | |
89 */ | |
90 @Override | |
91 public boolean isUsed() { | |
92 // Only GYP targets that are APKs and have the 'use_chromium_linker' var
iable | |
93 // defined as 1 will use this linker. For all others (the default), the | |
94 // auto-generated NativeLibraries.sUseLinker variable will be false. | |
95 return NativeLibraries.sUseLinker; | |
96 } | |
97 | |
98 /** | |
99 * Call this method to determine if the linker will try to use shared RELROs | 87 * Call this method to determine if the linker will try to use shared RELROs |
100 * for the browser process. | 88 * for the browser process. |
101 */ | 89 */ |
102 @Override | 90 @Override |
103 public boolean isUsingBrowserSharedRelros() { | 91 public boolean isUsingBrowserSharedRelros() { |
104 // This Linker does not attempt to share RELROS between the browser and | 92 // This Linker does not attempt to share RELROS between the browser and |
105 // the renderers, but only between renderers. | 93 // the renderers, but only between renderers. |
106 return false; | 94 return false; |
107 } | 95 } |
108 | 96 |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 * @param loadAddress load address, which can be different from the one | 483 * @param loadAddress load address, which can be different from the one |
496 * used to load the library in the current process! | 484 * used to load the library in the current process! |
497 * @param relroPath Path to the shared RELRO file for this library. | 485 * @param relroPath Path to the shared RELRO file for this library. |
498 * @param libInfo libInfo instance. On success, the mRelroStart, mRelroSize | 486 * @param libInfo libInfo instance. On success, the mRelroStart, mRelroSize |
499 * and mRelroFd will be set. | 487 * and mRelroFd will be set. |
500 * @return true on success, false otherwise. | 488 * @return true on success, false otherwise. |
501 */ | 489 */ |
502 private static native boolean nativeCreateSharedRelro( | 490 private static native boolean nativeCreateSharedRelro( |
503 String dlopenExtPath, long loadAddress, String relroPath, LibInfo li
bInfo); | 491 String dlopenExtPath, long loadAddress, String relroPath, LibInfo li
bInfo); |
504 } | 492 } |
OLD | NEW |