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/namespacebuilder.h"
21 
22 #include "linkerconfig/common.h"
23 #include "linkerconfig/environment.h"
24 
25 using android::linkerconfig::modules::GetVendorVndkVersion;
26 using android::linkerconfig::modules::Namespace;
27 
28 namespace android {
29 namespace linkerconfig {
30 namespace contents {
BuildVendorDefaultNamespace(const Context & ctx)31 Namespace BuildVendorDefaultNamespace([[maybe_unused]] const Context& ctx) {
32   Namespace ns("default", /*is_isolated=*/true, /*is_visible=*/true);
33 
34   ns.AddSearchPath("/odm/${LIB}");
35   ns.AddSearchPath("/vendor/${LIB}");
36   ns.AddSearchPath("/vendor/${LIB}/hw");
37   ns.AddSearchPath("/vendor/${LIB}/egl");
38 
39   ns.AddPermittedPath("/odm");
40   ns.AddPermittedPath("/vendor");
41   ns.AddPermittedPath("/system/vendor");
42 
43   ns.GetLink(ctx.GetSystemNamespaceName())
44       .AddSharedLib(
45           {Var("LLNDK_LIBRARIES_VENDOR"), Var("SANITIZER_DEFAULT_VENDOR")});
46   ns.GetLink("vndk").AddSharedLib({Var("VNDK_SAMEPROCESS_LIBRARIES_VENDOR"),
47                                    Var("VNDK_CORE_LIBRARIES_VENDOR")});
48   if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
49     ns.GetLink("vndk_in_system")
50         .AddSharedLib(Var("VNDK_USING_CORE_VARIANT_LIBRARIES"));
51   }
52 
53   ns.AddRequires(std::vector{"libneuralnetworks.so"});
54   return ns;
55 }
56 }  // namespace contents
57 }  // namespace linkerconfig
58 }  // namespace android
59