Commit graph

111 commits

Author SHA1 Message Date
Treehugger Robot
2fdf9da669 Merge "Don't install unnecessary VNDK libs" 2018-01-04 13:36:14 +00: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
Dimitry Ivanov
3f5b5dc546 Add comment to android_link_namespaces method
Test: n/a - comment only change
Bug: http://b/26833548
Change-Id: I40356eec37aeb864206982feb877c59c21c9a433
2017-02-13 08:52:35 -08:00
Dimitry Ivanov
fd87c062ab Merge "Replace public library list with shared lib sonames" 2017-02-11 19:26:50 +00:00
Dimitry Ivanov
26e1a846ef Replace public library list with shared lib sonames
Call updated interface in order to setup anonymous and classloader
namespaces

Bug: http://b/26833548
Test: build & boot angler
Change-Id: I1fae5d9c015f2026563eb64d986c622c1b68effb
2017-02-06 14:26:56 -08:00
Dimitry Ivanov
6b74258818 Merge "Log errors from loading public libraries" 2017-02-06 21:05:02 +00:00
Evan Ralston
15a264e65c Log errors from loading public libraries
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-06 11:05:35 -08:00
Jesse Hall
e7005979c2 dlext_namespace.h: Declare android_get_LD_LIBRARY_PATH
This allows clients creating their own namespace do so by modifying
the default library path, rather than hardcoding it multiple places in
the system.

Bug: 33531483
Test: build
Change-Id: I321e219392b38c235b220986e1520b49a4669863
(cherry picked from commit 823c266a8a)
2017-02-02 11:36:14 -08:00
Jesse Hall
b75d82b42a Make dlext_namespaces.h available to users of libnativeloader
Bug: 33531483
Test: build
Change-Id: I1da92e2b1437b6775a9d81fc6c1a2d4bacecbc04
(cherry picked from commit 0936d25371)
2017-02-02 11:36:04 -08:00
Mark Salyzyn
30f991f251 liblog: use log/log.h when utilizing ALOG macros
Test: compile
Bug: 30465923
Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943
2017-01-11 09:31:15 -08:00
Jaekyun Seok
86e80b9be0 Use shared lib of libutils, libz and libbase.
libutils, libz and libbase are being used as shared lib by many other
modules.
So using their shared lib will reduce total image size.

Size diffs on angler build image are as follows.

libziparchive.so  : 103844 -> 41680 (-62164)
libnativeloader.so:  50824 -> 25104 (-25720)
total             : (-87884)

Test: building succeeded, and the image was tested on angler.
Bug: 33056637
Change-Id: I015afe5b8f4d87d495b706e2e78d60f44a910e87
2016-12-22 07:03:26 +09:00
Dimitry Ivanov
d836ab005a Allow different namespace types for different classloaders
An app should be able to make cross-arch calls to different apps
via other app's Context.getClassLoader()

Bug: 32542970
Test: Boot fugu. Check that there are no linker-namespace
      related errors in the log.

Change-Id: I1593f4688bcde0121a5e24a707441a4935fa7dc4
2016-11-04 15:21:13 -07:00
Dimitry Ivanov
800083d229 Return nullptr from FindNamespaceByClassLoader for NB-enabled apps.
This function is always called by the frameworks in order to
initialize vulkan layer path. For NB apps returning nullptr
disables vulkan layer library lookup as expected.

Bug: http://b/32542970
Test: mm
Change-Id: I426b2b9f5ea7227b00f063ed6040f37bb2b4f21f
2016-11-01 14:48:45 -07:00
Zhenhua WANG
f2804e5985 Upgrade native bridge to version 3 to support namespace
Native bridge implements namespace related interfaces in version 3.
The namespace semantic here is same as Android dynamic linker's.
Native loader wraps library loading functions of dynamic linker and
native bridge. Thus, Android runtime is able to load native library
of different ISA on one device by calling native loader directly.

Bug: http://b/28242460
Test: mm && make test-art-host -j48
Change-Id: Idde2b9d99fb6ebe547407c716b5478a231f745a7
Signed-off-by: Zhenhua WANG <zhenhua.wang@intel.com>
2016-10-25 11:11:38 -07:00
Elliott Hughes
36e0d390a2 Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I18a1d816d63b64601485045070851f32d44e85eb
2016-10-10 14:31:12 -07:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
Colin Cross
627112a87e Merge \"libnativeloader: convert Android.mk to Android.bp\"
am: 5783dea065

Change-Id: I347c0822bbfcc351a36154391c4cd1bcaa3fc7c2
2016-07-28 10:53:40 +00:00
Colin Cross
d4ce20aa84 libnativeloader: convert Android.mk to Android.bp
Change-Id: I94d7cde3138f28bbd158d62b657af8448b4175fd
2016-07-27 10:36:36 -07:00
Christopher Ferris
1b4f54e878 Merge \"Add support to indicate bitness of public library.\"
am: 3fb358478f

Change-Id: Ia5a7580cb26dbafa5863ae5d85aaaccb62936921
2016-06-22 19:37:31 +00:00
Christopher Ferris
39da84b06c Add support to indicate bitness of public library.
For public vendor libraries, a vendor might have only a 32 bit
or only a 64 bit version of the library. Add a way to indicate this
in the public.libraries.txt files. The new format is:

  library.so 32

This indicates that this is a 32 bit only public library.

  library.so 64

This indicates that this is a 64 bit only public library.

Bug: 29370721
Bug: 29512261
(cherry picked from commit 6664a805ca)

Change-Id: Id52c8b61d5c802ce62edda7e25f2755f6f93d6b7
2016-06-22 11:21:21 -07:00
Dan Willemsen
823d5bbc20 Merge "Remove invalid uses of -l and -I" am: 5d6193c658
am: 9ae3c079dc

* commit '9ae3c079dca647869dcbc5a5075609f0895e4f4c':
  Remove invalid uses of -l and -I

Change-Id: Id0ddd34cee10579684cdde36f3c095658a50784b
2016-06-01 21:57:27 +00:00
Dan Willemsen
ee2da03e26 Remove invalid uses of -l and -I
LOCAL_LDLIBS should only be used with -l flags for NDK and some host
libraries. Other uses should use LOCAL_SHARED_LIBRARIES.

LOCAL_LDFLAGS should not contain -l entries, they should be in
LOCAL_LDLIBS instead.

LOCAL_CFLAGS should not contain -I entries, those should use
LOCAL_C_INCLUDES instead.

Change-Id: Ic901aa14651572ac682166becd4f0cd86baecc34
2016-06-01 13:41:23 -07:00
Dimitry Ivanov
fcd4ee48a4 Merge "Remove target_sdk_version parameter" into nyc-dev
am: 07f46c84e6

* commit '07f46c84e614e2635e8072403dce8f17cc9285ba':
  Remove target_sdk_version parameter

Change-Id: Idf4bca526e7a40064518ad0e5ccc5aa1f63dbe75
2016-05-24 17:15:12 +00:00
Dimitry Ivanov
94ee4e690d Remove target_sdk_version parameter
Since linker-namespaces are enabled for all target_sdk_versions
and there is no longer need in workarounds in libnativeloader -
remove unused target_sdk_version parameter for internal calls.

This also brings libnativeloader closer to aosp/master

Bug: http://b/26040253
Change-Id: I7d6f6ac31be0dca5f3c3f6ea20e6cc87ce3a3c7f
2016-05-24 08:40:38 -07:00
Dimitry Ivanov
e17c2efc4c Merge "Set parent namespace for linker-namespaces" am: ac50d0cc57
am: 3457aba394

* commit '3457aba39480e85d582dd6890c4c72e418958782':
  Set parent namespace for linker-namespaces

Change-Id: I20ea9239e95377894f477c33cf65bc7da7ad1e5a
2016-05-17 23:06:21 +00:00
Dimitry Ivanov
ade364b456 Set parent namespace for linker-namespaces
This change allows applications to share RTLD_GLOBAL
native libraries between namespaces associated with
different classloaders.

The rule is - if a library is GLOBAL within namespace
associated with parent classloader, it is shared
with namespace associated with this classloader

Note that the sharing happens on create_namespace
event, which is tied to createClassloader in case of
application classloaders created by the framework, for
custom application classloaders it is tied to first
loadLibrary() event.

Bug: http://b/28560538
Bug: https://code.google.com/p/android/issues/detail?id=208458
Change-Id: I7ee701166f8ec5eff033b7acc0f80c7aa4ec5bda
(cherry picked from commit 24db75c1ce)
2016-05-17 15:58:56 -07:00
Dimitry Ivanov
d98683f415 Pass permitted_path to the linker as is.
am: 25df4bff44

* commit '25df4bff44a0d1a342dc45521bf7e860b3fef947':
  Pass permitted_path to the linker as is.

Change-Id: Idf8459267f8e1cc7bebc9a55b1272871b3d8119a
2016-05-17 04:06:05 +00:00
Dimitry Ivanov
24db75c1ce Set parent namespace for linker-namespaces
This change allows applications to share RTLD_GLOBAL
native libraries between namespaces associated with
different classloaders.

The rule is - if a library is GLOBAL within namespace
associated with parent classloader, it is shared
with namespace associated with this classloader

Note that the sharing happens on create_namespace
event, which is tied to createClassloader in case of
application classloaders created by the framework, for
custom application classloaders it is tied to first
loadLibrary() event.

Bug: http://b/28560538
Bug: https://code.google.com/p/android/issues/detail?id=208458
Change-Id: I7ee701166f8ec5eff033b7acc0f80c7aa4ec5bda
2016-05-16 18:13:49 -07:00
Dimitry Ivanov
25df4bff44 Pass permitted_path to the linker as is.
Now that we have the fixed list of whitelisted libraries
there is no longer need to check if java_permitted_path is nullptr.
In fact checking it prevents custom classloaders created by apps
from loading libraries using absolute path.

Bug: http://b/28659864
Change-Id: I1bfc16a573b090f70f078ecccd0e4016939a5dc0
(cherry picked from commit b31caa95ec)
2016-05-16 18:09:15 -07:00
Dimitry Ivanov
b31caa95ec Pass permitted_path to the linker as is.
Now that we have the fixed list of whitelisted libraries
there is no longer need to check if java_permitted_path is nullptr.
In fact checking it prevents custom classloaders created by apps
from loading libraries using absolute path.

Bug: http://b/28659864
Change-Id: I1bfc16a573b090f70f078ecccd0e4016939a5dc0
2016-05-16 17:08:06 -07:00
Dimitry Ivanov
17decbd637 Merge "Move linker-namespace functions declarations" am: 37ed923d1c
am: 3f0a12622b

* commit '3f0a12622b8d35f1223945498a086e19c791bf24':
  Move linker-namespace functions declarations

Change-Id: I6f3e8b5ef608e3b930510b5c483ec6e7963eb4f7
2016-05-11 21:29:15 +00:00
Dimitry Ivanov
c337cae9ad Move linker-namespace functions declarations
They are intended for platform use only and we shouldn't have them
in the public header file. This CL moves them to libnativeloader
private header file.

Bug: http://b/28174921
Change-Id: I01cf446d2d8d7cf6f9e31130aa3d4e54fbbbb9fc
(cherry picked from commit 6796522256)
2016-05-11 14:20:12 -07:00
Dimitry Ivanov
37ed923d1c Merge "Move linker-namespace functions declarations" 2016-05-11 21:14:41 +00:00
Dimitry Ivanov
d7cbb6f053 Merge "nativeloader: Ignore empty java_permitted_path" into nyc-dev
am: 6edd0c3a68

* commit '6edd0c3a68f60541c31fd65080e52939f2be3bc2':
  nativeloader: Ignore empty java_permitted_path

Change-Id: I1777b3a05d2e233000815172cfa1e56326be634b
2016-05-11 05:03:07 +00:00
Dimitry Ivanov
72ca40f738 nativeloader: Ignore empty java_permitted_path
Passing empty permitted path should result in no-op.
This addresses review comment on CL with commit
f334cbf0e1

Bug: http://b/28639227
Change-Id: I4a4540e522e90a145a374939921932c86f35e88d
(cherry picked from commit d0b1531929)
2016-05-10 22:02:05 -07:00