aboutsummaryrefslogtreecommitdiff
path: root/en/devices/architecture/vndk
diff options
context:
space:
mode:
authorAndroid Partner Docs <noreply@android.com>2018-12-14 10:00:48 -0800
committerMark Hecomovich <mheco@google.com>2018-12-14 14:48:16 -0800
commitf2db2b61cb449bf1b0276974d1f4d0f73ef2b4dd (patch)
treec4cb2c473a1e89617ba7e1a874f040b0c2e1ae53 /en/devices/architecture/vndk
parent0929a40f7786a1f574c202f8bf01bf38fc5bdc03 (diff)
downloadsource.android.com-f2db2b61cb449bf1b0276974d1f4d0f73ef2b4dd.tar.gz
Docs: Changes to source.android.com
- 225558908 Automated g4 rollback of changelist 225461674. by Android Partner Docs <noreply@android.com> - 225550864 Devsite localized content from translation request 1036674. by Android Partner Docs <noreply@android.com> - 225547899 Fix broken link by Danielle Roberts <daroberts@google.com> - 225547403 Drop additional whitespace introduced by accident when tr... by Android Partner Docs <noreply@android.com> - 225536653 Add official guideline for headers for extended VNDK by Android Partner Docs <noreply@android.com> - 225489731 Devsite localized content from translation request 1015203. by Android Partner Docs <noreply@android.com> - 225489729 Devsite localized content from translation request 1047579. by Android Partner Docs <noreply@android.com> - 225489727 Devsite localized content from translation request 1047590. by Android Partner Docs <noreply@android.com> - 225465663 Fix typo by Android Partner Docs <noreply@android.com> - 225461674 Revert CID update by Danielle Roberts <daroberts@google.com> - 225458889 Add setup/build/dashboard to devsite; Link from homepage ... by Android Partner Docs <noreply@android.com> - 225452187 Update catching exceptions per Tobias' CL http://ag/57916... by Christina Nguyen <cqn@google.com> - 225410221 Created a guide to access work profile contacts. by Android Partner Docs <noreply@android.com> - 225380106 Devsite localized content from translation request 1044541. by Android Partner Docs <noreply@android.com> - 225280142 Remove holdover 9.0 directory from zh-cn localized files. by Gina Dimino <gdimino@google.com> - 225276176 Changing reviewer to gdimino by Gina Dimino <gdimino@google.com> - 225268401 Add benefits of Atest to introductory statement by Android Partner Docs <noreply@android.com> - 225268205 Fix "directorys" typo in TEST MAPPING doc by Android Partner Docs <noreply@android.com> - 225261448 Clean up the HTML formatting so that the file is easier f... by Christina Nguyen <cqn@google.com> - 225251081 Secure Element: Fix typos for few test cases by Android Partner Docs <noreply@android.com> - 225206956 Update build numbers for 2018/12 Docomo releases by Android Partner Docs <noreply@android.com> - 225195616 Devsite localized content from translation request 1046264. by Android Partner Docs <noreply@android.com> - 225195419 Devsite localized content from translation request 1024866. by Android Partner Docs <noreply@android.com> - 225195391 Devsite localized content from translation request 1040016. by Android Partner Docs <noreply@android.com> - 225195374 Devsite localized content from translation request 1032282. by Android Partner Docs <noreply@android.com> - 225059126 Secure Element: Add clarification on test cases by Android Partner Docs <noreply@android.com> - 225018931 Devsite localized content from translation request 1045477. by Android Partner Docs <noreply@android.com> - 224904315 Devsite localized content from translation request 1044282. by Android Partner Docs <noreply@android.com> - 224904309 Devsite localized content from translation request 1029445. by Android Partner Docs <noreply@android.com> - 224904295 Devsite localized content from translation request 1044542. by Android Partner Docs <noreply@android.com> - 224897168 Removed the comment tag and "Comming soon" for the local... by Luke Haviland <lhaviland@google.com> - 224891868 Add Luke to localization configs by Danielle Roberts <daroberts@google.com> - 224860068 Devsite localized content from translation request 1044262. by Android Partner Docs <noreply@android.com> - 224752674 Devsite localized content from translation request 1026891. by Android Partner Docs <noreply@android.com> - 224752671 Devsite localized content from translation request 1061530. by Android Partner Docs <noreply@android.com> - 224752667 Devsite localized content from translation request 1040025. by Android Partner Docs <noreply@android.com> - 224752636 Devsite localized content from translation request 1008389. by Android Partner Docs <noreply@android.com> - 224752634 Devsite localized content from translation request 1013269. by Android Partner Docs <noreply@android.com> - 224752628 Devsite localized content from translation request 1020396. by Android Partner Docs <noreply@android.com> - 224422875 Add link to Packaging Build Rules section anchor by Android Partner Docs <noreply@android.com> - 224421602 Move Atests links from AOSP to SAC, standardize envar setup by Android Partner Docs <noreply@android.com> - 224421460 Fix code example "MyLuiActivity" by Kenneth Lau <kennethlau@google.com> - 224420429 Fix incorrect starting path to all Atest links by Android Partner Docs <noreply@android.com> - 224417300 Replace AOSP link for Atest with native page by Android Partner Docs <noreply@android.com> - 224252988 Fix "Title Case" to "Sentence case" for H2 and lower. by Android Partner Docs <noreply@android.com> - 224233356 Fix broken link on APK Signing page by Kenneth Lau <kennethlau@google.com> - 224204432 Updated AOSP links by Luke Haviland <lhaviland@google.com> - 224200053 Added AOSP Links to December Bulletin. by Luke Haviland <lhaviland@google.com> - 224182129 Add Atest and Test Mapping to News section of home page by Android Partner Docs <noreply@android.com> - 224162840 Devsite localized content from translation request 1024730. by Android Partner Docs <noreply@android.com> - 224159473 Remove text regarding notification email group. by Android Partner Docs <noreply@android.com> - 224086085 Add terminal types to USB-C headset page by Danielle Roberts <daroberts@google.com> - 224072758 added row back to the functional patches table by Luke Haviland <lhaviland@google.com> - 224053547 Update build numbers for 2018/12 m/s releases by Android Partner Docs <noreply@android.com> - 224043334 Add WinScope developer documentation by Android Partner Docs <noreply@android.com> - 224032853 Move localized CDD file to 9 directory by Danielle Roberts <daroberts@google.com> - 224026519 Add Test Mapping docs to Tests Development section by Android Partner Docs <noreply@android.com> - 223922752 Enhance the documentation for ld.config.txt file format by Android Partner Docs <noreply@android.com> - 223920489 Devsite localized content from translation request 1040039. by Android Partner Docs <noreply@android.com> - 223920485 Devsite localized content from translation request 1040022. by Android Partner Docs <noreply@android.com> - 223857636 Update build numbers for 2018/12 releases by Android Partner Docs <noreply@android.com> - 223845531 Fix the Qualcomm table to exclude component and only read... by Luke Haviland <lhaviland@google.com> - 223816883 Adding the December security bulletins by Luke Haviland <lhaviland@google.com> - 223805280 Updated the CDD navigation to include the previous versio... by Luke Haviland <lhaviland@google.com> - 223799250 Devsite localized content from translation request 1036673. by Android Partner Docs <noreply@android.com> - 223799221 Devsite localized content from translation request 1005914. by Android Partner Docs <noreply@android.com> - 223799216 Devsite localized content from translation request 1015209. by Android Partner Docs <noreply@android.com> - 223799211 Devsite localized content from translation request 1034359. by Android Partner Docs <noreply@android.com> - 223587266 Clarify disabled HALs by Android Partner Docs <noreply@android.com> - 223457102 Devsite localized content from translation request 1034369. by Android Partner Docs <noreply@android.com> - 223450822 Devsite localized content from translation request 1036675. by Android Partner Docs <noreply@android.com> - 223365433 Minor style edits by Christina Nguyen <cqn@google.com> - 223364760 Fix typo. by Christina Nguyen <cqn@google.com> - 223361317 Devsite localized content from translation request 1018906. by Android Partner Docs <noreply@android.com> - 223356382 Correct repo location for bluecross kernel by Android Partner Docs <noreply@android.com> - 223176719 Devsite localized content from translation request 1024867. by Android Partner Docs <noreply@android.com> - 223176706 Devsite localized content from translation request 1020251. by Android Partner Docs <noreply@android.com> - 223097181 Devsite localized content from translation request 1013714. by Android Partner Docs <noreply@android.com> - 222999852 Devsite localized content from translation request 1024727. by Android Partner Docs <noreply@android.com> - 222999831 Devsite localized content from translation request 1008230. by Android Partner Docs <noreply@android.com> - 222999739 Devsite localized content from translation request 1022537. by Android Partner Docs <noreply@android.com> - 222999726 Devsite localized content from translation request 1026861. by Android Partner Docs <noreply@android.com> - 222999709 Devsite localized content from translation request 1028231. by Android Partner Docs <noreply@android.com> - 222906457 Add Atest docs to Tests section by Kenneth Lau <kennethlau@google.com> - 222886182 Devsite localized content from translation request 1019176. by Android Partner Docs <noreply@android.com> PiperOrigin-RevId: 225558908 Change-Id: I318551b443def5e3a8f402c1585d0ad4f986276a
Diffstat (limited to 'en/devices/architecture/vndk')
-rw-r--r--en/devices/architecture/vndk/build-system.html211
-rw-r--r--en/devices/architecture/vndk/linker-namespace.html496
2 files changed, 578 insertions, 129 deletions
diff --git a/en/devices/architecture/vndk/build-system.html b/en/devices/architecture/vndk/build-system.html
index 72737be6..98e95b63 100644
--- a/en/devices/architecture/vndk/build-system.html
+++ b/en/devices/architecture/vndk/build-system.html
@@ -506,18 +506,19 @@ $(call add-clean-step, rm -rf $(TARGET_OUT_VENDOR)/lib/libvndk.so)
</p>
<ul>
- <li>core variant (e.g. <code>/system/lib[64]/libexample.so</code>)</li>
- <li>vendor variant (e.g.
+ <li>Core variant (e.g. <code>/system/lib[64]/libexample.so</code>)</li>
+ <li>Vendor variant (e.g.
<code>/system/lib[64]/vndk[-sp]-${VER}/libexample.so</code>)</li>
<li>VNDK extension (e.g. <code>/vendor/lib[64]/vndk[-sp]/libexample.so</code>)
</li>
</ul>
+
<h4 id="conditional-cflags">Conditional compiler flags</h4>
<p>
The Android build system defines <code>__ANDROID_VNDK__</code> for vendor
- variants (including VNDK extensions) by default. You may guard the code
+ variants and VNDK extensions by default. You may guard the code
with the C preprocessor guards:
</p>
@@ -537,15 +538,18 @@ void vndk_only() { }
In addition to <code>__ANDROID_VNDK__</code>, different <code>cflags</code> or
<code>cppflags</code> may be specified in <code>Android.bp</code>. The
<code>cflags</code> or <code>cppflags</code> specified in
- <code>target.vendor</code> is specific to the vendor variant. For example, the
- following code example is the <code>Android.bp</code> module definition for
+ <code>target.vendor</code> is specific to the vendor variant.
+</p>
+
+<p>
+ For example, the following <code>Android.bp</code> defines
<code>libexample</code> and <code>libexample_ext</code>:
</p>
<pre class="prettyprint">
cc_library {
name: "libexample",
- srcs: ["example.c"],
+ srcs: ["src/example.c"],
vendor_available: true,
vndk: {
enabled: true,
@@ -559,7 +563,7 @@ cc_library {
cc_library {
name: "libexample_ext",
- srcs: ["example.c"],
+ srcs: ["src/example.c"],
vendor: true,
vndk: {
enabled: true,
@@ -573,7 +577,7 @@ cc_library {
</pre>
<p>
- Code listing of <code>example.c</code>:
+ And this is the code listing of <code>src/example.c</code>:
</p>
<pre class="prettyprint">
@@ -593,7 +597,8 @@ void vndk_ext() { }
</pre>
<p>
- Exported symbols for each variant:
+ According to these two files, the build system generates shared libraries
+ with following exported symbols:
</p>
<table>
@@ -618,19 +623,34 @@ void vndk_ext() { }
</tr>
</table>
+
+<h4 id="exported-symbols">Requirements on the exported symbols</h4>
+
<p>
- The VNDK ABI compliance checker compares the ABI of VNDK and VNDK
- extensions to the ABI dumps under <code>prebuilts/abi-dumps/vndk</code>:
+ The <a href="/devices/architecture/vndk/abi-stability">VNDK ABI checker</a>
+ compares the ABI of <em>VNDK vendor variants</em> and
+ <em>VNDK extensions</em> to the reference ABI dumps under
+ <code>prebuilts/abi-dumps/vndk</code>.
</p>
<ul>
- <li>Symbols exported by original VNDK shared libraries must be identical to
- (not the supersets of) the symbols defined in ABI dumps.</li>
- <li>Symbols exported by VNDK extensions must be supersets of the symbols
- defined in ABI dumps.</li>
+ <li>Symbols exported by <em>VNDK vendor variants</em> (e.g.
+ <code>/system/lib[64]/vndk-${VER}/libexample.so</code>) must be identical
+ to (not the supersets of) the symbols defined in ABI dumps.</li>
+
+ <li>Symbols exported by <em>VNDK extensions</em> (e.g.
+ <code>/vendor/lib[64]/vndk/libexample.so</code>) must be supersets of the
+ symbols defined in ABI dumps.</li>
</ul>
-<h4 id="excluding">Excluding source files or shared libs</h4>
+<p>
+ If <em>VNDK vendor variants</em> or <em>VNDK extensions</em> fail to follow
+ the requirements above, VNDK ABI checker emits build errors and stops the
+ build.
+</p>
+
+
+<h4 id="excluding">Excluding source files or shared libraries from vendor variants</h4>
<p>
To exclude source files from the vendor variant, add them to the
@@ -641,7 +661,7 @@ void vndk_ext() { }
<pre class="prettyprint">
cc_library {
- name: "libcond_exclude_example",
+ name: "libexample_cond_exclude",
srcs: ["fwk.c", "both.c"],
shared_libs: ["libfwk_only", "libboth"],
target: {
@@ -654,17 +674,168 @@ cc_library {
</pre>
<p>
- In this example, the core variant of <code>libcond_exclude_example</code>
+ In this example, the core variant of <code>libexample_cond_exclude</code>
includes the code from <code>fwk.c</code> and <code>both.c</code> and depends
on the shared libraries <code>libfwk_only</code> and <code>libboth</code>. The
- vendor variant of <code>libcond_exclude_example</code> includes only the code
+ vendor variant of <code>libexample_cond_exclude</code> includes only the code
from <code>both.c</code> because <code>fwk.c</code> is excluded by the
<code>exclude_srcs</code> property. Similarly,
- <code>libcond_exclude_example</code> depends only on the shared library
+ <code>libexample_cond_exclude</code> depends only on the shared library
<code>libboth</code> because <code>libfwk_only</code> is excluded by the
<code>exclude_shared_libs</code> property.
</p>
+<h4 id="export-headers-from-vndk-extension">Export headers from VNDK extensions</h4>
+
+<p>
+ A VNDK extension may add new classes or new functions to a VNDK shared
+ library. It is suggested to keep those declarations in independent headers
+ and avoid changing the existing headers.
+</p>
+
+<p>
+ For example, a new header file
+ <code>include-ext/example/ext/feature_name.h</code> is created for the VNDK
+ extension <code>libexample_ext</code>:
+</p>
+
+<ul>
+ <li>Android.bp</li>
+ <li><strong>include-ext/example/ext/feature_name.h</strong></li>
+ <li>include/example/example.h</li>
+ <li>src/example.c</li>
+ <li><strong>src/ext/feature_name.c</strong></li>
+</ul>
+
+<p>
+ In the following <code>Android.bp</code>, <code>libexample</code> exports
+ only <code>include</code>, whereas <code>libexample_ext</code> exports both
+ <code>include</code> and <code>include-ext</code>. This ensures
+ <code>feature_name.h</code> won't be incorrectly included by the users of
+ <code>libexample</code>:
+</p>
+
+<pre class="prettyprint">
+cc_library {
+ name: "libexample",
+ srcs: ["src/example.c"],
+ export_include_dirs: ["include"],
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+}
+
+cc_library {
+ name: "libexample_ext",
+ srcs: [
+ "src/example.c",
+ "src/ext/feature_name.c",
+ ],
+ export_include_dirs: [
+ "include",
+ "include-ext",
+ ],
+ vendor: true,
+ vndk: {
+ enabled: true,
+ extends: "libexample",
+ },
+}
+</pre>
+
+<p>
+ If separating extensions to independent header files is not feasible, an
+ alternative is to add <code>#ifdef</code> guards. However, make sure that all
+ VNDK extension users add the define flags. You may define
+ <code>cc_defaults</code> to add define flags to <code>cflags</code> and link
+ shared libraries with <code>shared_libs</code>.
+</p>
+
+<p>
+ For example, to add a new member function <code>Example2::get_b()</code> to
+ the VNDK extension <code>libexample2_ext</code>, you must modify the existing
+ header file and add a <code>#ifdef</code> guard:
+</p>
+
+<pre class="prettyprint">
+#ifndef LIBEXAMPLE2_EXAMPLE_H_
+#define LIBEXAMPLE2_EXAMPLE_H_
+
+class Example2 {
+ public:
+ Example2();
+
+ void get_a();
+
+#ifdef LIBEXAMPLE2_ENABLE_VNDK_EXT
+ void get_b();
+#endif
+
+ private:
+ void *impl_;
+};
+
+#endif // LIBEXAMPLE2_EXAMPLE_H_
+</pre>
+
+<p>
+ A <code>cc_defaults</code> named <code>libexample2_ext_defaults</code> is
+ defined for the users of <code>libexample2_ext</code>:
+</p>
+
+<pre class="prettyprint">
+cc_library {
+ name: "libexample2",
+ srcs: ["src/example2.cpp"],
+ export_include_dirs: ["include"],
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+}
+
+cc_library {
+ name: "libexample2_ext",
+ srcs: ["src/example2.cpp"],
+ export_include_dirs: ["include"],
+ vendor: true,
+ vndk: {
+ enabled: true,
+ extends: "libexample2",
+ },
+ cflags: [
+ "-DLIBEXAMPLE2_ENABLE_VNDK_EXT=1",
+ ],
+}
+
+cc_defaults {
+ name: "libexample2_ext_defaults",
+ shared_libs: [
+ "libexample2_ext",
+ ],
+ cflags: [
+ "-DLIBEXAMPLE2_ENABLE_VNDK_EXT=1",
+ ],
+}
+</pre>
+
+<p>
+ The users of <code>libexample2_ext</code> may simply include
+ <code>libexample2_ext_defaults</code> in their <code>defaults</code>
+ property:
+</p>
+
+<pre class="prettyprint">
+cc_binary {
+ name: "example2_user_executable",
+ defaults: ["libexample2_ext_defaults"],
+ vendor: true,
+}
+</pre>
+
+
+
<h3 id="product-packages">Product packages</h3>
<p>
diff --git a/en/devices/architecture/vndk/linker-namespace.html b/en/devices/architecture/vndk/linker-namespace.html
index b0d82512..a460e158 100644
--- a/en/devices/architecture/vndk/linker-namespace.html
+++ b/en/devices/architecture/vndk/linker-namespace.html
@@ -46,7 +46,7 @@ hiding their implementation details within their linker namespaces.</p>
<p>For example, <code>/system/lib[64]/libcutils.so</code> and
<code>/system/lib[64]/vndk-sp-${VER}/libcutils.so</code> are two shared
-libraries. These two libraries may have different symbols. They will be loaded
+libraries. These two libraries may have different symbols. They are loaded
into different linker namespaces so that framework modules can depend on
<code>/system/lib[64]/libcutils.so</code> and SP-HAL shared libraries can
depend on <code>/system/lib[64]/vndk-sp-${VER}/libcutils.so</code>.</p>
@@ -55,7 +55,7 @@ depend on <code>/system/lib[64]/vndk-sp-${VER}/libcutils.so</code>.</p>
public libraries that is exported by a linker namespace and imported into
many linker namespaces. The dependencies of
<code>/system/lib[64]/libc.so</code>, such as <code>libnetd_client.so</code>,
-will be loaded into the namespace in which <code>/system/lib[64]/libc.so</code>
+is loaded into the namespace in which <code>/system/lib[64]/libc.so</code>
resides. Other namespaces won't have accesses to those dependencies. This
mechanism encapsulates the implementation details while providing the public
interfaces.</p>
@@ -69,10 +69,10 @@ interfaces.</p>
<p>The dynamic linker is responsible for loading the shared libraries specified
in <code>DT_NEEDED</code> entries or the shared libraries specified by the
argument of <code>dlopen()</code> or <code>android_dlopen_ext()</code>. In both
-cases, the dynamic linker will find the linker namespace where the caller
+cases, the dynamic linker finds the linker namespace where the caller
resides and try to load the dependencies into the same linker namespace. If
the dynamic linker cannot load the shared library into the specified linker
-namespace, it will ask the <em>linked linker namespace</em> for exported shared
+namespace, it asks the <em>linked linker namespace</em> for exported shared
libraries.</p>
@@ -86,130 +86,408 @@ configuration file looks like:</p>
<pre class="prettyprint">
dir.system = /system/bin
+dir.system = /system/xbin
dir.vendor = /vendor/bin
[system]
-additional.namespaces = sphal
+additional.namespaces = sphal,vndk
namespace.default.isolated = true
-namespace.default.search.paths = /system/${LIB}:/vendor/${LIB}
-namespace.default.permitted.paths = /system/${LIB}:/vendor/${LIB}
+namespace.default.search.paths = /system/${LIB}
+namespace.default.permitted.paths = /system/${LIB}/hw
+namespace.default.asan.search.paths = /data/asan/system/${LIB}:/system/${LIB}
+namespace.default.asan.permitted.paths = /data/asan/system/${LIB}/hw:/system/${LIB}/hw
namespace.sphal.isolated = true
namespace.sphal.visible = true
-namespace.sphal.search.paths = /vendor/${LIB}
-namespace.sphal.permitted.paths = /vendor/${LIB}
-namespace.sphal.links = default
+namespace.sphal.search.paths = /odm/${LIB}:/vendor/${LIB}
+namespace.sphal.permitted.paths = /odm/${LIB}:/vendor/${LIB}
+namespace.sphal.asan.search.paths = /data/asan/odm/${LIB}:/odm/${LIB}
+namespace.sphal.asan.search.paths += /data/asan/vendor/${LIB}:/vendor/${LIB}
+namespace.sphal.asan.permitted.paths = /data/asan/odm/${LIB}:/odm/${LIB}
+namespace.sphal.asan.permitted.paths += /data/asan/vendor/${LIB}:/vendor/${LIB}
+namespace.sphal.links = default,vndk
namespace.sphal.link.default.shared_libs = libc.so:libm.so
+namespace.sphal.link.vndk.shared_libs = libbase.so:libcutils.so
+
+namespace.vndk.isolated = true
+namespace.vndk.search.paths = /system/${LIB}/vndk-sp-29
+namespace.vndk.permitted.paths = /system/${LIB}/vndk-sp-29
+namespace.vndk.links = default
+namespace.vndk.link.default.shared_libs = libc.so:libm.so
[vendor]
namespace.default.isolated = false
namespace.default.search.paths = /vendor/${LIB}:/system/${LIB}
-namespace.default.permitted.paths = /vendor/${LIB}:/system/${LIB}
</pre>
-<p>First, there are several <code>dir.${section}</code> properties at the
-beginning of <code>ld.config.txt</code>:</p>
+<p>The configuration file includes:</p>
-<pre class="prettyprint">
-dir.${section} = /path/to/bin/directory
-</pre>
+<ul>
+ <li>Several directory-section mapping properties at the beginning for the
+ dynamic linker to select the effective section.</li>
-<p>These properties decide which set of rules will be applied to the process.
-For example, if a <em>main executable</em> resides in <code>/system/bin</code>,
-the rules in the <code>[system]</code> section are applied. Similarly, if a
-<em>main executable</em> resides in <code>/vendor/bin</code>, the rules in the
-<code>[vendor]</code> section are applied.</p>
+ <li>
+ Several linker namespaces configuration sections:
-<p>Second, for each section, in addition to the <code>default</code> linker
-namespace, <code>addition.namespaces</code> specifies the extra linker
-namespaces (separated by comma) that will be created by the dynamic
-linker:</p>
+ <ul>
+ <li>Each section contains several namespaces (graph vertices) and several
+ fallback links between namespaces (graph arcs).</li>
-<pre class="prettyprint">
-additional.namespaces = namespace1,namespace2,namespace3
-</pre>
+ <li>Each namespace has its own isolation, search paths, permitted paths,
+ and visibility settings.</li>
+ </ul>
+ </li>
+</ul>
-<p>In the example above, the dynamic linker creates two linker namespaces
-(<code>default</code> and <code>sphal</code>) for the executables in
-<code>/system/bin</code>.</p>
+<p>The tables below describe the meaning of each property in detail.</p>
-<p>Third, for each linker namespace, following properties can be configured:</p>
-<pre class="prettyprint">
-namespace.${name}.search.paths = /path1/${LIB}:/path2/${LIB}
-namespace.${name}.permitted.paths = /path1:/path2
-namespace.${name}.isolated = true|false
-namespace.${name}.links = namespace1,namespace2
-namespace.${name}.link.${other}.shared_libs = lib1.so:lib2.so
-namespace.${name}.link.${other}.allow_all_shared_libs = true
-namespace.${name}.visible = true|false
-</pre>
-<p><code>namespace.${name}.search.paths</code> denotes the directories that
-will be prepended to the library name. Directories are separated by colons.
-<code>${LIB}</code> is a special placeholder. If the process is running a
-32-bit executable, <code>${LIB}</code> is substituted by
-<code>lib</code>. Similarly, if the process is running a 64-bit executable,
-<code>${LIB}</code> is substituted by <code>lib64</code>.</p>
-
-<p>In the example above, if a 64-bit executable in <code>/system/bin</code>
-links with <code>libexample.so</code>, the dynamic linker searches for
-<code>/system/lib64/libexample.so</code> first. If
-<code>/system/lib64/libexample.so</code> is not available, the dynamic
-linker searches for <code>/vendor/lib64/libexample.so</code>.</p>
-
-<p>If <code>namespace.${name}.isolated</code> is <code>true</code>, the
-dynamic linker loads only the shared libraries in the directories specified
-in <code>namespace.${name}.search.paths</code> or the shared libraries under
-the directories specified in
-<code>namespace.${name}.permitted.paths</code>.</p>
-
-<p>In the example above, a shared library that is loaded in the
-<code>sphal</code> linker namespace won't be able to link to shared libraries
-in <code>/system/lib[64]</code> because <code>namespace.sphal.isolated</code>
-is <code>true</code> and <code>/system/lib[64]</code> is in neither
-<code>namespace.sphal.permitted.paths</code> nor
-<code>namespace.sphal.search.paths</code>.</p>
-
-<p><code>namespace.${name}.links</code> specifies a comma-separated list of
-linker namespaces that the <code>${name}</code> linker namespace links to.</p>
-
-<p>In the example above, <code>namespace.sphal.links</code> specifies that the
-<code>sphal</code> linker namespace links to the <code>default</code> linker
-namespace.</p>
-
-<p><code>namespace.${name}.link.${other}.shared_libs</code> specifies the
-shared library names (separated by colons) that may utilize the fallback link.
-If a shared library can't be loaded into the <code>${name}</code> linker
-namespace and its name is in
-<code>namespace.${name}.link.${other}.shared_libs</code>, the dynamic linker
-will try to import the library from the <code>${other}</code> linker
-namespace.</p>
-
-<p>In the example above, <code>namespace.sphal.link.default.shared_libs</code>
-specifies that <code>libc.so</code> and <code>libm.so</code> may be exported by
-the <code>default</code> linker namespace. If a shared library loaded in the
-<code>sphal</code> linker namespace links to <code>libc.so</code> and the
-dynamic linker cannot find <code>libc.so</code> in
-<code>/vendor/lib[64]</code>, the dynamic linker will walk through the
-fallback link and find the <code>libc.so</code> exported by the
-<code>default</code> linker namespace.</p>
-
-<p>If <code>namespace.${name}.link.${other}.allow_all_shared_libs</code> is
-<code>true</code>, all shared library names may utilize the fallback link. If
-a shared library can't be loaded into the <code>${name}</code> linker
-namespace, the dynamic linker will try to import the library from the
-<code>${other}</code> linker namespace.</p>
-
-<p>If <code>namespace.${name}.visible</code> is <code>true</code>, the
-program will be able to obtain a linker namespace handle, which can be passed
-to <code>android_dlopen_ext()</code> later.</p>
-
-<p>In the example above, the <code>namespace.sphal.visible</code> is
-<code>true</code> so that <code>android_load_sphal_library()</code> can
-explicitly ask the dynamic linker to load a shared library in the
-<code>sphal</code> linker namespace.</p>
+<h3 id="directory-section-mapping-property">Directory-section mapping property</h3>
+
+<table>
+ <tr>
+ <th>Property</th>
+ <th>Description</th>
+ <th>Example</th>
+ </tr>
+
+ <tr>
+ <td><p><code>dir.<var>name</var></code></p></td>
+
+ <td>
+ <p>A path to a directory that the <code>[<var>name</var>]</code> section
+ applies to.</p>
+
+ <p>Each property maps the executables under the directory to a linker
+ namespaces configuration section. There might be two (or more) properties
+ with the same <code><var>name</var></code> but point to different
+ directories.</p>
+ </td>
+
+ <td>
+ <p>
+ <code>dir.system = /system/bin</code><br/>
+ <code>dir.system = /system/xbin</code><br/>
+ <code>dir.vendor = /vendor/bin</code><br/>
+ </p>
+
+ <p>This indicates that the configuration specified in the
+ <code>[system]</code> section applies to the executables that are loaded
+ from either <code>/system/bin</code> or <code>/system/xbin</code>.</p>
+
+ <p>The configuration specified in the <code>[vendor]</code> section applies
+ to the executables that are loaded from <code>/vendor/bin</code>.</p>
+ </td>
+ </tr>
+</table>
+
+
+
+<h3 id="relation-properties">Relation properties</h3>
+
+<table>
+ <tr>
+ <th>Property</th>
+ <th>Description</th>
+ <th>Example</th>
+ </tr>
+
+ <tr>
+ <td><code>additional.<wbr/>namespaces</code></td>
+
+ <td>
+ <p>A comma-separated list of additional namespaces (in addition to the
+ <code>default</code> namespace) for the section.</p>
+ </td>
+
+ <td>
+ <p><code>additional.<wbr/>namespaces = sphal,<wbr/>vndk</code></p>
+
+ <p>This indicates there are three namespaces (<code>default</code>,
+ <code>sphal</code>, and <code>vndk</code>) in the <code>[system]</code>
+ configuration.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>links</code></td>
+
+ <td>
+ <p>A comma-separated list of fallback namespaces.</p>
+
+ <p>If a shared library cannot be found in the current namespace, the dynamic
+ linker tries to load the shared library from the fallback namespaces. The
+ namespace specified at the beginning of the list has higher priority.</p>
+
+ <aside class="note">Note: Fallback namespaces are not transitive. For
+ example, namespace <em>A</em> links to namespace <em>B</em> and namespace
+ <em>B</em> links to namespace <em>C</em>. If the dynamic linker can not
+ find the library in namespace <em>A</em>, it ONLY searches namespace
+ <em>B</em>. It doesn't search namespace <em>C</em>.</aside>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>sphal.<wbr/>links = default,<wbr/>vndk</code></p>
+
+ <p>If a shared library or an executable requests a shared library that
+ cannot be loaded into the <code>sphal</code> namespace, the dynamic linker
+ tries to load the shared library from the <code>default</code>
+ namespace.</p>
+
+ <p>And then, if the shared library cannot be loaded from the
+ <code>default</code> namespace either, the dynamic linker tries to load the
+ shared library from the <code>vndk</code> namespace.</p>
+
+ <p>Finally, if all attempts fail, the dynamic linker returns an error.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>link.<wbr/><var>other</var>.<wbr/>shared_libs</code></td>
+
+ <td>
+ <p>A colon-separated list of shared libraries that can be searched in the
+ <code>other</code> namespaces when those libraries cannot be found in the
+ <code>name</code> namespace.</p>
+
+ <p>This property cannot be used with
+ <code>namespace.<wbr/><var>name</var>.<wbr/>link.<wbr/><var>other</var>.<wbr/>allow_all_shared_libs</code>.</p>
+
+ <aside class="note"><p>Note: This property shares the same underlying
+ implementation with
+ <a href="/devices/tech/config/namespaces_libraries">public.libraries.txt</a>
+ files. Both mechanisms control the imported shared libraries by specifying a
+ link with a library name filter.</p>
+
+ <p>The difference is that <code>ld.config.txt</code> is loaded by the
+ dynamic linker and all namespaces are created when a program starts. On the
+ contrary, <code>libnativeloader</code> creates a linker namespace when the
+ Zygote process is forked and specialized for an application. The namespace
+ for the application native libraries has a link that only allows the library
+ names specified in <code>public.libraries.txt</code>.</p></aside>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>sphal.<wbr/>link.<wbr/>default.<wbr/>shared_libs = libc.so:<wbr/>libm.so</code></p>
+
+ <p>This indicates that the fallback link only accepts <code>libc.so</code>
+ or <code>libm.so</code> as the requested library name. The dynamic linker
+ ignores the fallback link from <code>sphal</code> to
+ <code>default</code> namespace if the requested library name is not
+ <code>libc.so</code> nor <code>libm.so</code>.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>link.<wbr/><var>other</var>.<wbr/>allow_all_shared_libs</code></td>
+
+ <td>
+ <p>A boolean value that indicates whether all shared libraries can be
+ searched in the <code><var>other</var></code> namespace when those libraries cannot
+ be found in the <code><var>name</var></code> namespace.</p>
+
+ <p>This property cannot be used with
+ <code>namespace.<wbr/><var>name</var>.<wbr/>link.<wbr/><var>other</var>.<wbr/>shared_libs</code>.</p>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>vndk.<wbr/>link.<wbr/>sphal.<wbr/>allow_all_shared_libs = true</code></p>
+
+ <p>This indicates all library names can walk through the fallback link
+ from <code>vndk</code> to <code>sphal</code> namespace.</p>
+ </td>
+ </tr>
+</table>
+
+
+
+<h3 id="namespace-properties">Namespace properties</h3>
+
+<table>
+ <tr>
+ <th>Property</th>
+ <th>Description</th>
+ <th>Example</th>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>isolated</code></td>
+
+ <td>
+ <p>A boolean value that indicates whether the dynamic linker should check
+ where the shared library resides.</p>
+
+ <p>If <code>isolated</code> is <code>true</code>, only the shared libraries
+ that are <em>in</em> one of the <code>search.paths</code> directories
+ (excluding sub-directories) or are <em>under</em> one of the
+ <code>permitted.paths</code> directories (including sub-directories) can be
+ loaded.</p>
+
+ <p>If <code>isolated</code> is <code>false</code> (default), the dynamic
+ linker doesn't check the path of shared libraries.</p>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>sphal.<wbr/>isolated = true</code></p>
+
+ <p>This indicates that only the shared libraries in
+ <code>search.paths</code> or under <code>permitted.paths</code> can be
+ loaded into the <code>sphal</code> namespace.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>search.paths</code></td>
+
+ <td>
+ <p>A colon-separated list of directories to search for shared
+ libraries.</p>
+
+ <p>The directories specified in <code>search.paths</code> are prepended
+ to the requested library name if function calls to <code>dlopen()</code> or
+ <code>DT_NEEDED</code> entries do not specify the full path. The directory
+ specified at the beginning of the list has higher priority.</p>
+
+ <p>When <code>isolated</code> is <code>true</code>, shared libraries that
+ are <em>in</em> one of the <code>search.paths</code> directories (excluding
+ sub-directories) can be loaded regardless the <code>permitted.paths</code>
+ property.</p>
+
+ <p>For example, if <code>search.paths</code> is
+ <code>/system/${LIB}</code> and <code>permitted.paths</code> is empty,
+ <code>/system/${LIB}/libc.so</code> can be loaded but
+ <code>/system/${LIB}/vndk/libutils.so</code> cannot be loaded.</p>
+
+ <aside class="note">Note: <code>${LIB}</code> is a built-in
+ placeholder. It is replaced by <code>lib</code> for 32-bit processes and
+ <code>lib64</code> for 64-bit processes.</aside>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>default.<wbr/>search.paths = /system/${LIB}</code></p>
+
+ <p>This indicates that the dynamic linker searches
+ <code>/system/${LIB}</code> for shared libraries.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>asan.search.paths</code></td>
+
+ <td>
+ <p>A colon-separated list of directories to search for shared libraries when
+ <a href="/devices/tech/debug/asan">Address Sanitizer</a> is enabled.</p>
+
+ <p><code>namespace.<wbr/><var>name</var>.<wbr/>search.paths</code> is
+ ignored when <a href="/devices/tech/debug/asan">Address Sanitizer</a> is
+ enabled.</p>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>default.<wbr/>asan.search.paths = /data/asan/system/${LIB}:<wbr/>/system/${LIB}</code></p>
+
+ <p>This indicates that when
+ <a href="/devices/tech/debug/asan">Address Sanitizer</a> is enabled the
+ dynamic linker searches <code>/data/asan/system/${LIB}</code> first and
+ then searches <code>/system/${LIB}</code>.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>permitted.paths</code></td>
+
+ <td>
+ <p>A colon-separated list of directories (including sub-directories) where
+ the dynamic linker can load the shared libraries (in addition to
+ <code>search.paths</code>) when <code>isolated</code> is
+ <code>true</code>.</p>
+
+ <p>The shared libraries that are under the sub-directories of
+ <code>permitted.paths</code> can be loaded too. For example, if
+ <code>permitted.paths</code> is <code>/system/${LIB}</code>,
+ both <code>/system/${LIB}/libc.so</code> and
+ <code>/system/${LIB}/vndk/libutils.so</code> can be loaded.</p>
+
+ <p>If <code>isolated</code> is <code>false</code>,
+ <code>permitted.paths</code> are ignored and a warning is emitted.</p>
+
+ <aside class="note">Note: <code>permitted.paths</code> are NOT
+ prepended to the requested library names when the dynamic linker is
+ searching for a shared library. Its main purpose is to allow programers to
+ load shared libraries into an isolated namespace by specifying the full path
+ of the shared library.</aside>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>default.<wbr/>permitted.paths = /system/${LIB}/hw</code></p>
+
+ <p>This indicates that the shared libraries under
+ <code>/system/${LIB}/hw</code> can be loaded into the isolated
+ <code>default</code> namespace.</p>
+
+ <p>For example, without <code>permitted.paths</code>,
+ <code>libaudiohal.so</code> won't be able to load
+ <code>/system/${LIB}/hw/audio.a2dp.default.so</code> into the
+ <code>default</code> namespace.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>asan.permitted.paths</code></td>
+
+ <td>
+ <p>A colon-separated list of directories where the dynamic linker can load
+ the shared libraries when <a href="/devices/tech/debug/asan">Address
+ Sanitizer</a> is enabled.</p>
+
+ <p><code>namespace.<wbr/><var>name</var>.<wbr/>permitted.paths</code> is
+ ignored when <a href="/devices/tech/debug/asan">Address Sanitizer</a> is
+ enabled.</p>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>default.<wbr/>asan.permitted.paths = /data/asan/system/${LIB}/hw:<wbr/>/system/${LIB}/hw</code></p>
+
+ <p>This indicates that when
+ <a href="/devices/tech/debug/asan">Address Sanitizer</a> is enabled shared
+ libraries under <code>/data/asan/system/${LIB}/hw</code> or
+ <code>/system/${LIB}/hw</code> can be loaded to the isolated
+ <code>default</code> namespace.</p>
+ </td>
+ </tr>
+
+ <tr>
+ <td><code>namespace.<wbr/><var>name</var>.<wbr/>visible</code></td>
+
+ <td>
+ <p>A boolean value that indicates whether the program (other than
+ <code>libc</code>) can obtain a linker namespace handle with
+ <code>android_get_exported_namespace()</code> and open a shared library in
+ the linker namespace by passing the handle to
+ <code>android_dlopen_ext()</code>.</p>
+
+ <p>If <code>visible</code> is <code>true</code>,
+ <code>android_get_exported_namespace()</code> always returns the handle if
+ the namespace exists.</p>
+
+ <p>If <code>visible</code> is <code>false</code> (default),
+ <code>android_get_exported_namespace()</code> always returns
+ <code>NULL</code> regardless the presence of the namespace. Shared libraries
+ can only be loaded into this namespace if (1) they are requested by another
+ linker namespace that has a fallback link to this namespace or (2) they are
+ requested by other shared libraries or executables in this namespace.</p>
+ </td>
+
+ <td>
+ <p><code>namespace.<wbr/>sphal.<wbr/>visible = true</code></p>
+
+ <p>This indicates that <code>android_get_exported_namespace("sphal")</code>
+ can return a valid linker namespace handle.</p>
+ </td>
+ </tr>
+</table>
@@ -217,11 +495,11 @@ explicitly ask the dynamic linker to load a shared library in the
<h2 id="linker-namespace-isolation">Linker namespace isolation</h2>
-<p>There are three configurations in
+<p>There are three configuration files in
<code>${android-src}/system/core/rootdir/etc</code>. Depending on the value of
<code>PRODUCT_TREBLE_LINKER_NAMESPACES</code>, <code>BOARD_VNDK_VERSION</code>,
and <code>BOARD_VNDK_RUNTIME_DISABLE</code> in <code>BoardConfig.mk</code>,
-different configurations will be selected:</p>
+different configurations are selected:</p>
<table>
<tr>
@@ -282,7 +560,7 @@ BOARD_VNDK_RUNTIME_DISABLE := true
<p>If <code>BOARD_VNDK_RUNTIME_DISABLE</code> is <code>true</code>,
<code>${android-src}/system/core/rootdir/etc/ld.config.vndk_lite.txt</code>
-will be installed.</p>
+is installed.</p>
@@ -436,7 +714,7 @@ processes, which is excerpted from the <code>[system]</code> section in
<code>/product/app</code><br/>
<code>/product/priv-app</code><br/>
<code>/data</code><br/>
- <code>/mnt/expand
+ <code>/mnt/expand</code>
</td>
</tr>