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 is the default linker namespace for a vendor process (a process started
18 // from /vendor/bin/*).
19 
20 #include "linkerconfig/environment.h"
21 #include "linkerconfig/namespacebuilder.h"
22 
23 using android::linkerconfig::modules::Namespace;
24 
25 namespace android {
26 namespace linkerconfig {
27 namespace contents {
28 Namespace BuildProductDefaultNamespace([[maybe_unused]] const Context& ctx) {
29   Namespace ns("default", /*is_isolated=*/true, /*is_visible=*/true);
30 
31   ns.AddSearchPath(Var("PRODUCT", "product") + "/${LIB}");
32   ns.AddPermittedPath(Var("PRODUCT", "product"));
33 
34   ns.GetLink(ctx.GetSystemNamespaceName())
35       .AddSharedLib(
36           {Var("LLNDK_LIBRARIES_PRODUCT"), Var("SANITIZER_DEFAULT_PRODUCT")});
37   ns.GetLink("vndk").AddSharedLib({Var("VNDK_SAMEPROCESS_LIBRARIES_PRODUCT"),
38                                    Var("VNDK_CORE_LIBRARIES_PRODUCT")});
39   if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
40     ns.GetLink("vndk_in_system")
41         .AddSharedLib(Var("VNDK_USING_CORE_VARIANT_LIBRARIES"));
42   }
43   ns.AddRequires(std::vector{
44       "libneuralnetworks.so",
45   });
46   return ns;
47 }
48 }  // namespace contents
49 }  // namespace linkerconfig
50 }  // namespace android
51