A lib with 'nopreload' option in public.libraries.txt is not preloaded
during zygote. This is useful for seldom used public libraries; they
don't contribute to the zygote startup time and only affect the apps
that they are used.
Bug: 132911956
Test: libnativeloader_test
Change-Id: I6f97c90e6721aec7f2f96c8fc7b963b34f8edd3e
Explicitly initialize the pointer member `app_main_namespace_` of the
class LibraryNamespaces.
Test: atest libnativeloader_tests
Change-Id: I3932e7fb3c4074a127fcdbdedbd9c88652a7e36c
Don't create anonymous namespace separately, use the first namespace
that is created for app classloader as the anonymous namespace.
Note that the anonymous namespace is set via the new
ANDROID_NAMESPACE_TYPE_ALSO_USED_AS_ANONYMOUS. I didn't creat a new
function like android_set_anonymous_namespace as it requires uprev of
the libnativebridge interface and makes it harder to delete the old
android_init_anonymous_namespace as we have to keep it until all
proprietary bridged loaders are updated.
Bug: 130388701
Test: CtsBionicTestCases
Test: run games on http://www.monogame.net/showcase/?Android
Change-Id: I0fdd614365eaa56c4ab47538bf3772d94bd9ae55
This fixes a regression caused by 8f4afc8298
that libnativeloader can't no longer handle the case that it has failed
to find the default namespace. Previously before the change,
libnativeloader continued to use nullptr as the parent namespace which
is reconized as the default namespace inside the linker.
This change recovers the previous behavior. When the default namespace
is not found, NativeLoaderNamespace object is constructed from nullptr.
Bug: 138607234
Test: run app-compat/app-startup-gce on cf_x86_phone using forrest
Change-Id: If518fbc055399b73e7d3a6b45ace0f71e9c25dae
(cherry picked from commit db825ceba6)
Merged-In: If518fbc055399b73e7d3a6b45ace0f71e9c25dae
When a new namespace is added to ld.config.txt, it has to be reflected
to native_loader_test.cpp. However, failing to do so crashes the test
instead of showing an error message that the namespace hasn't been
added.
Fixing the issue by not returning nullptr when the namespace isn't
found.
Bug: 138304345
Test: libnativeloader_test
Change-Id: I9eee1293956caac69f95a946604a2e6f665bde89
Remove the out parameters for error messages using Result<T>.
Bug: 130388701
Test: libnativeloader_test
Change-Id: Idbaf391c183fb20d5e1d7c96f3a4ccbf9745b7e6
Just before the test is enabled, the neuralnetwork namespace was added
by https://android-review.googlesource.com/c/platform/system/core/+/1014637.
This is breaking the libnativeloader_test.
Fix the test by adding the code for the new namespace.
Bug: 138304345
Test: libnativeloader_test on aosp_cf_x86_phone
Change-Id: Ifa762e395a3b9b5debdbcfcbcb395eeda3a1b2a4
The link to the spahal namespace is not done when there is no lib in
vendor/etc/public.libraries.txt
Bug: 130388701
Test: libnativeloader_test on cuttlefish
Change-Id: I38f2d01305bca5ea942573484a0e0b9b44b1c0be
Makes updated libneuralnetworks.so in /apex/com.android.neuralnetworks/{LIB}
loadable from all relevant namespaces.
Test: Verified that right library is being loaded using lsof and
Test: verbose debug logs from bionic/ld.
Bug: 137320025
Change-Id: I38140bb9915a3f85f10456e15ed0f492dbdba802
libnativeloader hasn't had a unit test. Now we have it. The unittest
mocks calls to libdl, libbridgedloader, and JNI using gmock.
Not all tests are added yet. To ease the review, a few tests for core
scenarios are added.
Bug: 130388701
Test: libnativeloader_test
Change-Id: I518512047da66b44bc99cec26e2c34ba4985cca3
The `char* path` argument of OpenNativeLibrary() can be nullptr. We are
constructing std::string from the path, which is a bug. Fixing it by
using char* without converting it to std::string.
Test: run-gtests.sh
JniCompilerTest.CompileAndRunIntMethodThroughStubNormalCompiler
is successful.
Change-Id: I91249da7c1a72a2dff9bc77e477b465e0c7ee056
This change is to be in sync with other libraries in system/core.
External headers are included via #include <...> rather
than #include "...", which is for headers from the current library.
Bug: 130388701
Test: build & pass presubmit tests
Change-Id: Ifb87ebaea1b0ff95e2e79352e6a42e3bfd949c52
- *_public_libraries() are now thread-safe
- removed some of the duplicated code
Bug: 130388701
Test: build & pass presubmit tests
Change-Id: I34b5149f75e28bb892cffe8fd9070be886d2f9bd
Functions for reading the public libraries list are moved out of
library_namespace.cpp to public_libraries.cpp.
In addition, library-local symbols are moved from android namespace to
android::nativeloader namespace.
Bug: 130388701
Test: build & pass presubmit tests
Change-Id: If82419598304d56d29bfec4ef553443c788d0f53
native_loader.cpp is too crowded. Move the classes
NativeLoaderNamespaces and LibraryNamespaces out of native_loader.cpp to
their own source files.
This change does not alter any functionality.
Bug: 130388701
Test: m, presubmit tests
Change-Id: Ibc61ec0dc6727af7cac865b1971ebf1befac6855
This relands http://r.android.com/951440:
This affected binaries in the Runtime APEX, where the platform namespace is
"platform" rather than "default".
Also extend ANDROID_ADDITIONAL_PUBLIC_LIBRARIES to create links to both to
platform and runtime namespaces, so that it can be used to open up access to
internal libraries in the Runtime APEX as well, which is used by ART gtests
and run tests.
Also update some comments in the ld.config*.txt files to accurately explain
why some namespaces need to be visible, and some other minor changes for
consistency. There are no semantically significant changes in those files.
Test: Flash and boot
Test: Run an ART run test with the internal libarttest.so library
Test: lunch aosp_cf_x86_phone-eng;
atest android.compilation.cts.AdbRootDependentCompilationTest#testCompile_curProfile \
com.android.cts.dexmetadata.InstallDexMetadataHostTest#testProfileSnapshotAfterInstall \
installd_dexopt_test
Bug: 130293232
Bug: 121117762
Change-Id: I3d9f2102a03e83843e15bc78b5ad347220c52769
This reverts commit 4ca0ca67bf.
Reason for revert: Breaks android.compilation.cts.AdbRootDependentCompilationTest#testCompile_curProfile and others: http://g/art-team/R2nEDA1Ka_s
Change-Id: Ia6285648133d21e61040efafc73cac97d702a7c4
This affected binaries in the Runtime APEX, where the platform namespace is
"platform" rather than "default".
Also extend ANDROID_ADDITIONAL_PUBLIC_LIBRARIES to create links to both to
platform and runtime namespaces, so that it can be used to open up access to
internal libraries in the Runtime APEX as well, which is used by ART gtests
and run tests.
Also update some comments in the ld.config*.txt files to accurately explain
why some namespaces need to be visible, and some other minor changes for
consistency. There are no semantically significant changes in those files.
Test: Flash and boot
Test: Run an ART run test with the internal libarttest.so library
Bug: 130293232
Bug: 121117762
Change-Id: I7ebaf5370dd0f533b1bb5f0e67e7c3c1df48e512
Create the anonymous namespace only from a non-empty library path.
This is a better heuristic than the current "first-come" one. It
allows creating classloaders that are not directly related to an
app's "main" classloader, that is, do not have any library path.
This is the case, for example, for shared libraries, including
preloaded ones.
Longer-term, the anonymous namespace creation should be made
explicit, so that the framework can have full control.
Bug: 130623656
Test: m
Test: manual
Change-Id: I8251363b372e365d10ae09d23df93d76388ac7f9
platform private symbols have been moved to libdl_android.so
since they are not intended to be accessible from apps.
Test: make
Bug: http://b/129387775
Change-Id: I883a6d2ca588a258dd43efa766fad4e07428594e
(cherry picked from commit e3d0383d38)
Some of the legacy devices may not have vndk namespace. To make this
work, libnativeloader should not fail when it fails to search for vndk
namespace.
Bug: 129011845
Test: m -j
Change-Id: I6f68aeb6ae84a00985cc20561b2fcdb461be9724
Merged-In: Id9147d4aeee9ba2b301b6893dea5884dce9c14fa
Currently libnativeloader appends vendor lib path if apk is from vendor
partition. Similar to this we should add product lib path if apk if from product partition.
Bug: 124705551
Test: m -j && tested from crosshatch with product apps (such as Wallpaper)
Change-Id: I8c3473f1f70b1c22dcaed7eb2d5f9c3deee9e1a5
Merged-In: I8690167ca8098015c8ae4bbb4f028404c5e94dc0
Passing nullptr as parent namespace to android_create_namespace makes it use
the namespace of the caller as parent, which typically is the runtime
namespace. That in turn causes classloader-namespace to inherit any
libraries in the shared group of the runtime namespace, i.e. any libraries
that have been loaded in it with RTLD_GLOBAL or DF_1_GLOBAL up to that
point.
Let's instead pass the platform namespace from the linker config as fallback
when a parent namespace cannot be found. That is also what happened before
libnativeloader moved into the runtime namespace.
Test: Flash and boot
Test: atest CtsJniTestCases (on cuttlefish and taimen)
Bug: 124501296
Change-Id: If2faee74e2bdcf95d19516faec340fedcdd07e29
libnativeloader is in the Runtime Module, libcutils is not.
Dependency was on property_get so moving to libbase equivalent.
Bug: b/125323247
Test: m -j100
Change-Id: I295ffa14b475a193a851db89dbb3b4c9cc0183d2
libnativeloader_lazy and libnativebridge_lazy are shim libraries for
libnativeloader and libnativebridge, respectively.
The shim libraries provides the same APIs as their counterparts, but
when the APIs are called, the APIs from the real libraries are
loaded/linked/and executed using dlopen/dlsym.
Bug: 123403798
Bug: 124250621
Test: m
Test: device boots to the UI
Test: mma under system/core/libnativebridge with aosp_cf_x86
adb sync; execute all tests under
/data/nativetest/libnativebridge-lazy-tests
All passes except NativeBridgeTest.V2_Signal which is also failing
in /data/nativetest/libnativebridge-tests.
Change-Id: Ic6484784eaa7872dcdd2decbb30943fb34c1abd7
These libs are listed in public.android.txt, but not exposed in the default namespace
Bug: 120786417
Bug: 121372395
Test: app can still DT_NEEDED libicuuc.so
Change-Id: I03dc51f04e29c2d15679c4daf82b05a812efb2db
This reverts commit 5c8c6a90fd.
Reason for revert: Another try with http://r.android.com/892234 in place.
Test: Flash and boot
Bug: 113373927
Change-Id: I508c217a177e9cdd65d8a405d1315aeeacabe18d
This callback replaces getVendorNamespace(). Fix nativeloader
to use NativeBridgeGetExportedNamespace instead of
NativeBridgeGetVendorNamespace.
Bug: http://b/121248172
Bug: http://b/121372395
Test: make
Change-Id: I8fa2081e37815f6f65490c9536bed0687b7f1e77
This reverts commit 67a09e5791.
Exempt-From-Owner-Approval: Fixes P0 failures.
Bug: 123185917
Reason for revert: media namespace needs to be introduced.
Change-Id: I0c28798a3143c1e627278c3a908207e670171416