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 #include "linkerconfig/namespacebuilder.h"
18 
19 #include "linkerconfig/common.h"
20 #include "linkerconfig/environment.h"
21 #include "linkerconfig/namespace.h"
22 
23 using android::linkerconfig::modules::AsanPath;
24 using android::linkerconfig::modules::Namespace;
25 
26 namespace android {
27 namespace linkerconfig {
28 namespace contents {
29 Namespace BuildUnrestrictedDefaultNamespace([[maybe_unused]] const Context& ctx) {
30   Namespace ns("default", /*is_isolated=*/false, /*is_visible=*/true);
31 
32   ns.AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN);
33   ns.AddSearchPath(Var("SYSTEM_EXT") + "/${LIB}", AsanPath::WITH_DATA_ASAN);
34   ns.AddSearchPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
35   ns.AddSearchPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
36   ns.AddSearchPath(Var("PRODUCT") + "/${LIB}", AsanPath::WITH_DATA_ASAN);
37 
38   ns.AddRequires(std::vector{
39       // Keep in sync with the "platform" namespace in art/build/apex/ld.config.txt.
40       "libdexfile_external.so",
41       "libdexfiled_external.so",
42       "libnativebridge.so",
43       "libnativehelper.so",
44       "libnativeloader.so",
45       "libandroidicu.so",
46       // TODO(b/122876336): Remove libpac.so once it's migrated to Webview
47       "libpac.so",
48       // TODO(b/120786417 or b/134659294): libicuuc.so
49       // and libicui18n.so are kept for app compat.
50       "libicui18n.so",
51       "libicuuc.so",
52       // resolv
53       "libnetd_resolv.so",
54       // nn
55       "libneuralnetworks.so",
56       // statsd
57       "libstatspull.so",
58       "libstatssocket.so",
59   });
60 
61   ns.AddProvides(GetSystemStubLibraries());
62   return ns;
63 }
64 }  // namespace contents
65 }  // namespace linkerconfig
66 }  // namespace android
67