Commit graph

144 commits

Author SHA1 Message Date
Dimitry Ivanov
f6fd41c423 Merge "Add dependency on libdl_android" 2019-03-28 09:05:53 +00:00
Kiyoung Kim
ddbb6ed7e7 Do not fail when there is no vndk namespace
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: Id9147d4aeee9ba2b301b6893dea5884dce9c14fa
2019-03-25 13:48:43 +09:00
dimitry
e3d0383d38 Add dependency on libdl_android
platform private symbols have been moved to libdl_android.so
since they are not intended to be accessible from apps.

Test: make
Change-Id: I883a6d2ca588a258dd43efa766fad4e07428594e
2019-03-20 12:26:41 +01:00
Kiyoung Kim
cd8b96cb7c Add product apk support from libnativeloader
Currently libnativeloader appends vendor lib path if apk is from vendor
partition. Similar to this, as part of mainline core, 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: I8690167ca8098015c8ae4bbb4f028404c5e94dc0
2019-03-07 12:01:23 +09:00
Martin Stjernholm
7888b5cdd7 Avoid runtime namespace becoming parent for classloader-namespace.
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-23 03:46:27 +00:00
Orion Hodson
34b126b98b Remove dependency on libcutils
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-22 08:55:48 +00:00
vichang
ce912aadda Merge changes from topic "dup_icu4c"
* changes:
  Linker namespace changes for moving ICU4C to APEX
  Remove the public libs in runtime namespace
2019-02-19 10:14:31 +00:00
Jiyong Park
00f2ebe9cc shim libraries for libnativeloader and libnativebridge
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
2019-02-12 19:35:45 +09:00
Victor Chang
f70a2fe4c1 Remove the public libs in runtime namespace
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-08 13:34:09 +00:00
Martin Stjernholm
a015ad2779 Revert^2 "Enable APEX stubs for libnativeloader."
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
2019-02-07 15:23:49 +00:00
Martin Stjernholm
b78f6ec7ef Add some overview docs for classloader-namespace.
Courtesy of jiyong@.

Test: n/a
Change-Id: I4ee239c63a5b5f90516b05af25b32ff22b147d53
2019-02-06 21:51:27 +00:00
Victor Chang
7a20a907a5 Expose public libraries from runtime namepsace to classloader namespace
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-04 17:45:22 +00:00
dimitry
d2ace387f5 Add getExportedNamespace NB callback
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-02-04 15:06:43 +01:00
Martin Stjernholm
5c8c6a90fd Revert "Enable APEX stubs for libnativeloader."
This reverts commit 0daa405272.

Reason for revert: Breaks cf_x86_phone-userdebug: https://android-build.googleplex.com/builds/build-details/5273735/targets/cf_x86_phone-userdebug

Bug: 123700170
Change-Id: Id82a91f845120dd41ce02b6d7fef886a87eb23a8
2019-02-01 13:13:56 +00:00
Martin Stjernholm
0daa405272 Enable APEX stubs for libnativeloader.
Test: Flash and boot
Bug: 113373927
Change-Id: I61783b947031bb13f415e561e19cb90fa98d0ddd
2019-01-30 14:44:55 +00:00
Nicolas Geoffray
88bdf80d17 Conscrypt should only link against bionic.
Also remove useless code in native_loader.cpp

Test: m
Change-Id: Id176256cc36fa32d3f722e1443429cb9fbec05f2
2019-01-22 15:32:23 +00:00
Nicolas Geoffray
890e3bf4e7 Revert "Revert "Introduce conscrypt linker namespace.""
This reverts commit 5701a47685.

Bug: 123185917
Test: CtsJdwpTestCases
Test: android.signature.cts.api.killswitch_debug_class

Reason for revert: Fixed CtsJdwpTestCases and KillSwitchTest.

Change-Id: I6a074038a4e974875d68ca6a371f6a87ad48bce9
2019-01-22 09:15:22 +00:00
Nicolas Geoffray
5701a47685 Revert "Introduce conscrypt linker namespace."
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
2019-01-21 17:23:31 +00:00
Nicolas Geoffray
67a09e5791 Introduce conscrypt linker namespace.
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-21 12:05:13 +00:00
Nicolas Geoffray
5353502062 Pass the Java caller's location to OpenNativeLibrary.
Will be used to find the linker namespace to use.

Bug: 122874359
Test: m, gtest, run-test, CtsJdwpTests

Change-Id: I3f3be4a1d864741d585ab3ed9ffb93fab262516e
2019-01-18 14:07:27 +00:00
Nicolas Geoffray
ec6bd00f33 Merge "Add runtime module members to owners." 2019-01-17 06:58:06 +00:00
Nicolas Geoffray
7338ef5f5c Add runtime module members to owners.
Test: N/A
Change-Id: Id6cdf1a1b643df7744bf476e6e745ecc384708d7
2019-01-16 22:00:48 +00:00
Nicolas Geoffray
d06cb94d25 libnativeloader: remove stubs for now.
Seems to break VMDebug test.

Also add missed strdup in returned error message.

bug: 122957265
Test: VMDebug
Change-Id: I64727d707f20c0e6afcb5455edf20c99011a81dc
2019-01-16 21:40:34 +00:00
Nicolas Geoffray
c3a73dcd27 Move to C API of libnativeloader.
Test: m
Bug: 119840313
Bug: 122710865

(cherry picked from commit e1d970df09)

Merged-In: Id5b08ef5de0d38cb678a50e45d38dfb8107c4a1c
Change-Id: Ic82baa885caa5125dd3c8b5de854128c75f48caf

Exempt-From-Owner-Approval: Cherry-pick of approved CL in master.
2019-01-16 13:40:28 +00:00
Pete Bentley
632f142c42 Propagate dlopen errors to callers of OpenNativeLibrary.
Bug: 119867084
Test: make && flashall
Change-Id: If98082db39796f0097ce7ef1d095c9f202c3a95e
2018-12-19 13:48:01 +00:00
dimitry
3150f7c7af Add error_msg argument to CloseNativeLibrary
error_msg is set when dlclose/NativeBridgeUnloadLibrary fails.

Bug: https://issuetracker.google.com/79126103
Test: make
Change-Id: I043580209538ff47320e8d9a304a21c00c4b149f
2018-09-12 01:36:06 +02:00
Victor Khimenko
1443ec4972 Separate namespace acquisition from library loading
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-07-12 15:44:35 +02:00
Elliott Hughes
0ca7c79dfb libnativeloader: add jiyong to OWNERS.
Bug: N/A
Test: N/A
Change-Id: I892bfff4bcf28482588582a1045dcae720b121db
2018-05-31 18:09:20 -07:00
Inseob Kim
67cb05654c Support product-specific libraries
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-05-16 01:36:25 +00:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08:00
Jiyong Park
e031994f2f Don't shared oem-defined libs to vendor apks
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-15 22:08:21 +09:00
Treehugger Robot
01ccde321f Merge "Nativeloader: Add minimal effort for host library path" 2018-01-08 09:40:50 +00:00
Treehugger Robot
2fdf9da669 Merge "Don't install unnecessary VNDK libs" 2018-01-04 13:36:14 +00:00
Andreas Gampe
5c7d582be4 Nativeloader: Add minimal effort for host library path
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
2018-01-02 09:05:55 -08:00
Elliott Hughes
579e682628 Add std::string StartsWith*/EndsWith* overloads.
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-20 09:42:22 -08:00
Jiyong Park
d1006fe659 Support partners to expose their own system libs to Android apps
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-19 23:35:09 +09:00
Jiyong Park
9837d6be1f Don't install unnecessary VNDK libs
vndk_package is a phony module that includes ALL VNDK libs found in the
source code. As a result, VNDK libs that were actually not needed for
the device have been installed consuming storage. For example,
/system/lib/vndk/android.hardware.automotive*.so files were installed
even though walleye/taimen do not have automotive HALs.

VNDK libs are now installed by their link time dependencies (i.e. if a
vendor module uses libcutils, then /system/lib[64]/vndk-sp/libcutils.so
is automatically installed.).

By the way, there is a few number of VNDK libs that do not have any
link time dependency from vendor modules. They are always opened via
dlopen. In such cases, the vndk modules are added to `required`
or `LOCAL_REQUIRED_MODULES` of the module that dlopens them.

Bug: 67002788
Test: walleye builds and boots to the UI
Test: basic functionalities work (sound, camera, camcorder, slow-mo,
youtube, wifi, bluetooth)

Change-Id: I321256b9d20f20a9062c6d13b1745d8727eda558
2017-12-18 21:21:02 +09:00
Justin Yun
4a1d11038f Load versioned llndk.libraries.txt and vndksp.libraries.txt
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-12-13 10:27:28 +09:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Dan Willemsen
2c6b2ebe7c Merge "Remove default libraries" am: 8b7feee38f am: a0113de2f3
am: 55181f7cdd

Change-Id: I2fa1d556537ee4f3b2e67cd35aa3ce090b3684a6
2017-09-30 23:36:25 +00:00
Dan Willemsen
1e45d533b3 Remove default libraries
libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.

Test: m host
Change-Id: I0b3c147b00a8ab6ff289b85db55b88836c905f5c
Exempt-From-Owner-Approval: build system cleanup
2017-09-29 13:17:06 -07:00
Jiyong Park
25a03a23a8 Merge changes from topic "vndk_jni" into oc-mr1-dev
am: 6f7d928940

Change-Id: I69af1cdf06bf71f1125644c7064b40444613eaa7
2017-09-14 14:52:51 +00:00
Jiyong Park
a07f3057d0 vendor apk is unbundled
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-09-07 20:26:10 +09:00
Lennart Wieboldt
cd15fc7ba8 Remove LOCAL_CLANG and clang: true
clang is the default compiler since Android nougat

Test: mma & verified it´s still build with clang
Change-Id: I34adaeef2f6558a09f26027271222bad94780507
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 14:29:50 +02:00
Steven Moreland
00fe3ad728 system/core: use proper nativehelper headers
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-07-18 17:03:20 -07:00
Dimitry Ivanov
882cad2d87 Load vendor public libraries to sphal namespace
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 af0264bbe9)
2017-05-25 10:30:55 -07:00
Dimitry Ivanov
9e253ce6b7 Explicitly enable greylist for classloader-namespaces
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 058b2ea8c5)
2017-05-09 18:00:38 -07:00
Zhenhua WANG
e8fb11dfa1 NativeBridge: add "linked namespace" semantic corresponding to linker
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-03-29 17:34:11 -07:00
Calin Juravle
c169b2018f Set libnativeloader style to clang-format-2
Test: clang-format.py ...
Change-Id: I322c134c1e6b58b2c4ea21b6dfac5727860604c2
2017-03-29 17:33:12 -07:00