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.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.Parcel; | 8 import android.os.Parcel; |
9 import android.os.ParcelFileDescriptor; | 9 import android.os.ParcelFileDescriptor; |
10 import android.os.Parcelable; | 10 import android.os.Parcelable; |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 * Call this to send a Bundle containing the shared RELRO sections to be | 467 * Call this to send a Bundle containing the shared RELRO sections to be |
468 * used in this process. If initServiceProcess() was previously called, | 468 * used in this process. If initServiceProcess() was previously called, |
469 * finishLibraryLoad() will not exit until this method is called in another | 469 * finishLibraryLoad() will not exit until this method is called in another |
470 * thread with a non-null value. | 470 * thread with a non-null value. |
471 * @param bundle The Bundle instance containing a map of shared RELRO sectio ns | 471 * @param bundle The Bundle instance containing a map of shared RELRO sectio ns |
472 * to use in this process. | 472 * to use in this process. |
473 */ | 473 */ |
474 public static void useSharedRelros(Bundle bundle) { | 474 public static void useSharedRelros(Bundle bundle) { |
475 // Ensure the bundle uses the application's class loader, not the framew ork | 475 // Ensure the bundle uses the application's class loader, not the framew ork |
476 // one which doesn't know anything about LibInfo. | 476 // one which doesn't know anything about LibInfo. |
477 if (bundle != null) | 477 // Also, hold a fresh copy of it so the caller can't recycle it. |
478 Bundle nullOrCopy = null; | |
simonb (inactive)
2014/06/16 10:38:38
Perhaps a more descriptive variable name? clonedB
bulach
2014/06/16 21:54:55
Done.
| |
479 if (bundle != null) { | |
480 if (DEBUG) Log.i(TAG, "useSharedRelros() being DE-SER"); | |
simonb (inactive)
2014/06/16 10:38:38
Old debugging trace? Message seems unhelpful with
bulach
2014/06/16 21:54:55
ops, my bad. deleted.
| |
478 bundle.setClassLoader(LibInfo.class.getClassLoader()); | 481 bundle.setClassLoader(LibInfo.class.getClassLoader()); |
482 nullOrCopy = new Bundle(LibInfo.class.getClassLoader()); | |
483 Parcel p = Parcel.obtain(); | |
484 bundle.writeToParcel(p, 0); | |
485 nullOrCopy.readFromParcel(p); | |
486 p.recycle(); | |
487 } | |
479 | 488 |
480 if (DEBUG) Log.i(TAG, "useSharedRelros() called with " + bundle); | 489 if (DEBUG) Log.i(TAG, "useSharedRelros() called with " + nullOrCopy); |
simonb (inactive)
2014/06/16 10:38:38
No longer strictly accurate. Perhaps '... setting
bulach
2014/06/16 21:54:55
Done.
| |
481 | 490 |
482 synchronized (Linker.class) { | 491 synchronized (Linker.class) { |
483 // Note that in certain cases, this can be called before | 492 // Note that in certain cases, this can be called before |
484 // initServiceProcess() in service processes. | 493 // initServiceProcess() in service processes. |
485 sSharedRelros = bundle; | 494 sSharedRelros = nullOrCopy; |
486 // Tell any listener blocked in finishLibraryLoad() about it. | 495 // Tell any listener blocked in finishLibraryLoad() about it. |
487 Linker.class.notifyAll(); | 496 Linker.class.notifyAll(); |
488 } | 497 } |
489 } | 498 } |
490 | 499 |
491 /** | 500 /** |
492 * Call this to retrieve the shared RELRO sections created in this process, | 501 * Call this to retrieve the shared RELRO sections created in this process, |
493 * after loading all libraries. | 502 * after loading all libraries. |
494 * @return a new Bundle instance, or null if RELRO sharing is disabled on | 503 * @return a new Bundle instance, or null if RELRO sharing is disabled on |
495 * this system, or if initServiceProcess() was called previously. | 504 * this system, or if initServiceProcess() was called previously. |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 } | 1046 } |
1038 } | 1047 } |
1039 | 1048 |
1040 // The map of libraries that are currently loaded in this process. | 1049 // The map of libraries that are currently loaded in this process. |
1041 private static HashMap<String, LibInfo> sLoadedLibraries = null; | 1050 private static HashMap<String, LibInfo> sLoadedLibraries = null; |
1042 | 1051 |
1043 // Used to pass the shared RELRO Bundle through Binder. | 1052 // Used to pass the shared RELRO Bundle through Binder. |
1044 public static final String EXTRA_LINKER_SHARED_RELROS = | 1053 public static final String EXTRA_LINKER_SHARED_RELROS = |
1045 "org.chromium.base.android.linker.shared_relros"; | 1054 "org.chromium.base.android.linker.shared_relros"; |
1046 } | 1055 } |
OLD | NEW |