summaryrefslogtreecommitdiff
path: root/libnativeloader/native_loader.cpp
AgeCommit message (Collapse)Author
2019-10-09Move libnative{bridge,loader} to art/Orion Hodson
Bug: 137364733 Test: m Change-Id: I8fc0796745f7310f477fe9f8b0821586742dd9c0
2019-10-07Rename the runtime linker namespace following ART/Runtime APEX split.Martin Stjernholm
Remove the kludge in libnativeloader to deal with the inconsistency wrt the name of the APEX package. Test: Build & boot Test: atest system/core/libnativeloader (on cf_x86_phone) Bug: 139408016 Change-Id: I6115b49237c78c2ea4aa943ca4fe0b296b5a2b62
2019-08-30Update paths and names for the new ART APEX.Martin Stjernholm
Test: Build & boot Test: atest CtsJniTestCases Bug: 135753770 Exempt-From-Owner-Approval: Approved internally Change-Id: Ic59b7bc8aae7ce521cf3ec9df4ab72aa611d0b75 Merged-In: Ic59b7bc8aae7ce521cf3ec9df4ab72aa611d0b75
2019-07-26Use android::base::Result in libnativeloaderJiyong Park
Remove the out parameters for error messages using Result<T>. Bug: 130388701 Test: libnativeloader_test Change-Id: Idbaf391c183fb20d5e1d7c96f3a4ccbf9745b7e6
2019-05-16Fix style around header inclusionJiyong Park
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
2019-05-16Hide non-bridged/bridged namespaces behind NativeLoaderNamespace classJiyong Park
NativeLoaderNamespace fully abstracts the non-bridged (so called android-) and bridged namespaces. Bug: 130388701 Test: build & pass presubmit tests Change-Id: I3d5ca7515711e7638f4a5ab4d3a150185c3d17ac
2019-05-08Move public libraries list to a separate source fileJiyong Park
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
2019-05-04move classes out of native_loader.cppJiyong Park
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
2019-05-01Reland: Fix libnativeloader to correctly link to the platform namespace.Martin Stjernholm
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
2019-04-30Merge "Revert "Fix libnativeloader to correctly link to the platform ↵Treehugger Robot
namespace.""
2019-04-29Revert "Fix libnativeloader to correctly link to the platform namespace."Martin Stjernholm
This reverts commit 4ca0ca67bf466381e59865137e6811e863002984. Reason for revert: Breaks android.compilation.cts.AdbRootDependentCompilationTest#testCompile_curProfile and others: http://g/art-team/R2nEDA1Ka_s Change-Id: Ia6285648133d21e61040efafc73cac97d702a7c4
2019-04-29Merge "Nativeloader: Restrict anonymous namespace creation"Treehugger Robot
2019-04-29Fix libnativeloader to correctly link to the platform namespace.Martin Stjernholm
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
2019-04-26Nativeloader: Restrict anonymous namespace creationAndreas Gampe
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
2019-03-25Do not fail when there is no vndk namespaceKiyoung Kim
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
2019-03-07Add product apk support from libnativeloaderKiyoung Kim
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
2019-02-23Avoid runtime namespace becoming parent for classloader-namespace.Martin Stjernholm
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
2019-02-22Remove dependency on libcutilsOrion Hodson
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
2019-02-19Merge changes from topic "dup_icu4c"vichang
* changes: Linker namespace changes for moving ICU4C to APEX Remove the public libs in runtime namespace
2019-02-08Remove the public libs in runtime namespaceVictor Chang
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
2019-02-06Add some overview docs for classloader-namespace.Martin Stjernholm
Courtesy of jiyong@. Test: n/a Change-Id: I4ee239c63a5b5f90516b05af25b32ff22b147d53
2019-02-04Expose public libraries from runtime namepsace to classloader namespaceVictor Chang
Bug: 121248172 Bug: 121372395 Test: DT_NEEDED libicuuc.so Test: dlopen("libicuuc.so") Test: dlopen("/system/lib64/libicuuc.so") for targetSdkVersion < Q Test: dlopen("/apex/com.android.runtime/lib64/libicuuc.so") Change-Id: Ib4a255696ed474b7993acc952a8d07e7d64604a5
2019-02-04Add getExportedNamespace NB callbackdimitry
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
2019-01-22Conscrypt should only link against bionic.Nicolas Geoffray
Also remove useless code in native_loader.cpp Test: m Change-Id: Id176256cc36fa32d3f722e1443429cb9fbec05f2
2019-01-22Revert "Revert "Introduce conscrypt linker namespace.""Nicolas Geoffray
This reverts commit 5701a47685151f4a9f2417ad79f44e881e5101bb. Bug: 123185917 Test: CtsJdwpTestCases Test: android.signature.cts.api.killswitch_debug_class Reason for revert: Fixed CtsJdwpTestCases and KillSwitchTest. Change-Id: I6a074038a4e974875d68ca6a371f6a87ad48bce9
2019-01-21Revert "Introduce conscrypt linker namespace."Nicolas Geoffray
This reverts commit 67a09e57915de6ba2562ea4a5e16ee0ad4870e27. Exempt-From-Owner-Approval: Fixes P0 failures. Bug: 123185917 Reason for revert: media namespace needs to be introduced. Change-Id: I0c28798a3143c1e627278c3a908207e670171416
2019-01-21Introduce conscrypt linker namespace.Nicolas Geoffray
And have the linker translate a java library path from an apex to a linker namespace. Bug: 122874359 Test: m, boots, gtest, run-test, CtsJdwpTests Change-Id: I216c3509c45589d28acdac068aec53877aeb104a Exempt-From-Owner-Approval: Carrying Jiyong's +2
2019-01-18Pass the Java caller's location to OpenNativeLibrary.Nicolas Geoffray
Will be used to find the linker namespace to use. Bug: 122874359 Test: m, gtest, run-test, CtsJdwpTests Change-Id: I3f3be4a1d864741d585ab3ed9ffb93fab262516e
2019-01-16libnativeloader: remove stubs for now.Nicolas Geoffray
Seems to break VMDebug test. Also add missed strdup in returned error message. bug: 122957265 Test: VMDebug Change-Id: I64727d707f20c0e6afcb5455edf20c99011a81dc
2019-01-16Move to C API of libnativeloader.Nicolas Geoffray
Test: m Bug: 119840313 Bug: 122710865 (cherry picked from commit e1d970df09af55bbab9d9df438ff71088c7842d7) Merged-In: Id5b08ef5de0d38cb678a50e45d38dfb8107c4a1c Change-Id: Ic82baa885caa5125dd3c8b5de854128c75f48caf Exempt-From-Owner-Approval: Cherry-pick of approved CL in master.
2018-12-19Propagate dlopen errors to callers of OpenNativeLibrary.Pete Bentley
Bug: 119867084 Test: make && flashall Change-Id: If98082db39796f0097ce7ef1d095c9f202c3a95e
2018-09-12Add error_msg argument to CloseNativeLibrarydimitry
error_msg is set when dlclose/NativeBridgeUnloadLibrary fails. Bug: https://issuetracker.google.com/79126103 Test: make Change-Id: I043580209538ff47320e8d9a304a21c00c4b149f
2018-07-12Separate namespace acquisition from library loadingVictor Khimenko
This way native bridge namespace could be acquired in advance and when library must be loaded JNIEnv is not needed. Bug: http://b/79940628 Test: cts-tradefed run commandAndExit cts -m CtsGpuToolsHostTestCases Change-Id: If8bff272fc5245eb4e418807c3bdd29e82833ab8
2018-05-16Support product-specific librariesInseob Kim
Product-specific libraries in /product/lib can be exposed to Android apps by adding the list of the libs into /product/etc/public.libraries-<companyname>.txt. The libs MUST be named as lib<name>.<companyname>.so. Bug: 73095206 Test: with taimen mma -j and runtest.sh. The libs are all loaded in system, but not in vendor. After reinstalling app using adb -r and reopening app, only libraries listed in .txt are loaded Change-Id: I7c386813c72a7b225a7f244b6c5fec4ac0660fd3
2018-01-15Don't shared oem-defined libs to vendor apksJiyong Park
OEM-defined libs in /system/etc/public.libraries-<companyname>.txt files are not available to apks in the vendor partition, otherwise we are allowing vendor -> system dependency, which is a Treble violation. Bug: 71561542 Test: mm -j under system/core/libnativeloader/test and runtest.sh the four libs (lib[foo|bar].[oem1|oem2].so are all loaded in android.app.test.system app but not in android.app.test.vendor app Change-Id: Ie5d9160ae4dc2a64beb6507602ee5a1db6518875
2018-01-02Nativeloader: Add minimal effort for host library pathAndreas Gampe
Attempt to (somewhat) support the given library path on a non-Android device. Iterate through the given list and construct a complete path. This will of course not handle dependencies correctly and is best effort. Required (and enough) for agent-related testing in ART. Bug: 70901841 Test: m Change-Id: I9ecb27d662c8a2c79a70b6c5464483c449c5d034
2017-12-20Add std::string StartsWith*/EndsWith* overloads.Elliott Hughes
We should have done this from the beginning. Thanks to Windows, we're not going to be able to switch libbase over to std::string_view any time soon. Bug: N/A Test: ran tests Change-Id: Iff2f56986e39de53f3ac484415378af17dacf26b
2017-12-19Support partners to expose their own system libs to Android appsJiyong Park
Partners (entities other than AOSP) can expose their own system libraries which are in /system/lib[64] to Android apps. This can be done by adding the name of the libs into the files /system/etc/public.libraries-<companyname>.txt. There can be multiple of the txt files on a device, which is for the case that multiple partners contributing to the same system image have their own set of public libraries. The public libraries MUST be named as lib<name>.<companyname>.so. This is to prevent accidental exposure of AOSP-defined system private libs. Note 1: <companyname> doesn't need to be the same as the value of the sysprop ro.product.manufacturer or anything that can be part of a file path. Note 2: This feature is not for exposing SoC-specific libs to Android apps. That is already done by /vendor/etc/public.libraries.txt and is only for libs in /vendor/lib[64]. Bug: 68280171 Test: mm -j under /system/core/libnativeloader/test cts-tradefed run commandAndExit cts-dev -m CtsJniTestCases -t android.jni.cts.JniStaticTest#test_linker_namespaces Change-Id: I7d32ec27c7858e35b96c7c98223cc110acb35b81
2017-12-13Load versioned llndk.libraries.txt and vndksp.libraries.txtJustin Yun
When ro.vndk.version has a specific VNDK version in it, use the llndk.libraries.txt and vndksp.libraries.txt files with the version suffix in the file names. If ro.vndk.version is "current" or not set, the version suffix will not be added. This is to use a proper VNDK snapshot version configuration for a vendor patition. Bug: 69531793 Test: In system/etc directory of a Pixel2 device, Change llndk.libraries.txt to llndk.libraries.27.txt Change vndksp.libraries.txt to vndksp.libraries.27.txt Set ro.vndk.version to 27 in vendor/default.prop reboot and check if vendor apks work. Change-Id: I82d83b6805799ea71cc88d1e0297d265a40c0061
2017-09-07vendor apk is unbundledJiyong Park
For devices where VNDK restrictions are all enforced, vendor apks are recognized as unbundled; since system partition and vendor partition can be updated independently from each other. However, since vendor apks are still bundled in the vendor partition, they are allowed to do more than ordinaly unbundled apks that are downloaded and installed to the data partition. 1) /vendor/lib is allowed. So the path is added to the search_paths and permitted paths of the classloader namespace. 2) LLNDK libs are allowed in addition to the NDK libs. So, LLNDK lib list from llndk.libraries.txt is added to the list from public.libraries.txt. 3) VNDK-SP libs are allowed. To do so, the classloader namespace is linked to the 'vndk' namespace where VNDK-SP libs are searched and loaded from. The list of available VNDK-SP libs is read from vndksp.libraries.txt file. 4) Name of the namespace is changed to 'vendor-classloader-namespace' since the namespace is configured differently from the ordinary 'classloader-namespace'. Bug: 63553457 Test: 2017 pixel devices build and boots to the UI Test: a vendor apk (e.g. TimeService.apk) works. Turn the airplain mode on. Set time. Reboot the device. The time is not reset. Test: 1) set target as 2017 pixel 2) m -j CtsVendorJniTestCases 3) copy the built apk into /vendor/app/CtsVendorJniTestCases 4) reboot / factory reset 5) adb shell am instrument -w android.jni.vendor.cts Change-Id: I447452eb025c0a0fd076b5c9ac081d453dc6074e
2017-07-18system/core: use proper nativehelper headersSteven Moreland
libnativeheader exports headers under nativeheader. These were available before incorrectly as global headers in order to give access to jni.h. Test: modules using system/core find headers Bug: 63762847 Change-Id: I86240f7857dd815100cab32ad261aa9a0a54329c
2017-05-25Load vendor public libraries to sphal namespaceDimitry Ivanov
Load vendor public libraries to sphal namespace if it exists - preserve old behavior of loading these libraries to default namespace if sphal namespace is not present on the device. Bug: http://b/37410104 Test: cts-tradefed run singleCommand cts --skip-preconditions -m CtsJniTestCases on marlin (with enabled sphal configuration) and on angler where ld.config.txt is not present. Change-Id: Iaa3fa437ba2900acc2e5b9c78039fe1553e4c9dd (cherry picked from commit af0264bbe9f5e1228eb8fb486fa3d0d8e6e8605e)
2017-05-09Explicitly enable greylist for classloader-namespacesDimitry Ivanov
The linker no longer enables greylist by default, it needs to be explicitly enabled by specifying corresponding flag. Bug: https://issuetracker.google.com/38146125 Test: builds Change-Id: Ib593f2d9a35dbadffb436f5fbc9a2a7a8f64ada0 (cherry picked from commit 058b2ea8c52ed8ce33442eda3a39e49ecd11e6dd)
2017-03-29NativeBridge: add "linked namespace" semantic corresponding to linkerZhenhua WANG
For dynamic linking perspective, semantics of NativeBridge needs to align with dynamic linker. This patch adds "linked namespace" semantic which shares some libraries from one namespace to another. Test: make test-art-host-run-test-115-native-bridge Change-Id: I71ce1dde19d61363d5eb9731fd4795a8c315b3a0
2017-02-11Merge "Replace public library list with shared lib sonames"Dimitry Ivanov
2017-02-06Replace public library list with shared lib sonamesDimitry Ivanov
Call updated interface in order to setup anonymous and classloader namespaces Bug: http://b/26833548 Test: build & boot angler Change-Id: I1fae5d9c015f2026563eb64d986c622c1b68effb
2017-02-06Merge "Log errors from loading public libraries"Dimitry Ivanov
2017-02-06Log errors from loading public librariesEvan Ralston
Prevent the boot from failing silently if one of the public libraries does not exist. Test: Add invalid element to public libraries and observe log is emited during boot failure. Change-Id: I0425085a1cc081068954f327f15be853a3ccd553
2017-02-02Make dlext_namespaces.h available to users of libnativeloaderJesse Hall
Bug: 33531483 Test: build Change-Id: I1da92e2b1437b6775a9d81fc6c1a2d4bacecbc04 (cherry picked from commit 0936d25371e4f2618bf5760583a60dd542740542)
2017-01-11liblog: use log/log.h when utilizing ALOG macrosMark Salyzyn
Test: compile Bug: 30465923 Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943