1 /*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 // This namespace exposes externally accessible libraries from the ART APEX.
18 // Keep in sync with the "art" namespace in art/build/apex/ld.config.txt.
19
20 #include "linkerconfig/namespacebuilder.h"
21
22 using android::linkerconfig::modules::ApexInfo;
23 using android::linkerconfig::modules::AsanPath;
24 using android::linkerconfig::modules::Namespace;
25
26 namespace android {
27 namespace linkerconfig {
28 namespace contents {
29
BuildArtNamespace(const Context & ctx,const ApexInfo & apex)30 Namespace BuildArtNamespace([[maybe_unused]] const Context& ctx,
31 [[maybe_unused]] const ApexInfo& apex) {
32 // Make the namespace visible to allow links to be created at runtime, e.g.
33 // through android_link_namespaces in libnativeloader. That is not applicable
34 // to the vendor section.
35 Namespace ns(apex.namespace_name,
36 /*is_isolated=*/true,
37 /*is_visible=*/!ctx.IsVendorSection());
38
39 ns.AddSearchPath("/apex/com.android.art/${LIB}", AsanPath::SAME_PATH);
40 ns.AddPermittedPath("/system/${LIB}");
41
42 if (ctx.IsApexBinaryConfig()) {
43 // JVMTI libraries used in ART testing are located under /data; dalvikvm has
44 // to be able to dlopen them.
45 // TODO(b/129534335): Move this to the linker configuration of the Test ART
46 // APEX when it is available.
47 ns.AddPermittedPath("/data");
48
49 // odex files are in /system/framework and /apex/com.android.art/javalib.
50 // dalvikvm has to be able to dlopen the files for CTS.
51 ns.AddPermittedPath("/system/framework");
52 }
53
54 // Primary boot image is loaded through dlopen, so pass the primary boot image
55 // to the list of paths.
56 ns.AddPermittedPath("/apex/com.android.art/javalib", AsanPath::SAME_PATH);
57
58 // Need allow_all_shared_libs to let libart.so dlopen oat files in
59 // /system/framework and /data.
60 // TODO(b/130340935): Use a dynamically created linker namespace similar to
61 // classloader-namespace for oat files, and tighten this up.
62 ns.GetLink(ctx.GetSystemNamespaceName()).AllowAllSharedLibs();
63
64 ns.AddProvides(std::vector{
65 "libandroidicu.so",
66 "libandroidio.so",
67 "libdexfile_external.so",
68 "libdexfiled_external.so",
69 "libnativebridge.so",
70 "libnativehelper.so",
71 "libnativeloader.so",
72 // TODO(b/122876336): Remove libpac.so once it's migrated to Webview
73 "libpac.so",
74 // TODO(b/120786417 or b/134659294): libicuuc.so
75 // and libicui18n.so are kept for app compat.
76 "libicui18n.so",
77 "libicuuc.so",
78 });
79 ns.AddRequires(std::vector{
80 "libadbconnection_client.so",
81 "libc.so",
82 "libdl.so",
83 "libdl_android.so",
84 "liblog.so",
85 "libm.so",
86 // not listed in the manifest, but add here to preserve original configuration
87 "libneuralnetworks.so",
88 });
89
90 return ns;
91 }
92
93 } // namespace contents
94 } // namespace linkerconfig
95 } // namespace android
96