• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
22 #include <android-base/strings.h>
23 
24 #include "linkerconfig/namespacebuilder.h"
25 
26 using android::linkerconfig::modules::Namespace;
27 
28 namespace android {
29 namespace linkerconfig {
30 namespace contents {
BuildProductDefaultNamespace(const Context & ctx)31 Namespace BuildProductDefaultNamespace(const Context& ctx) {
32   return BuildProductNamespace(ctx, "default");
33 }
34 
BuildProductNamespace(const Context & ctx,const std::string & name)35 Namespace BuildProductNamespace(const Context& ctx, const std::string& name) {
36   Namespace ns(name, /*is_isolated=*/true, /*is_visible=*/true);
37 
38   ns.AddSearchPath(Var("PRODUCT", "product") + "/${LIB}");
39   ns.AddPermittedPath(Var("PRODUCT", "product"));
40 
41   AddLlndkLibraries(ctx, &ns, VndkUserPartition::Product);
42   ns.GetLink(ctx.GetSystemNamespaceName())
43       .AddSharedLib(Var("SANITIZER_DEFAULT_PRODUCT"));
44   if (ctx.IsSystemSection() || ctx.IsUnrestrictedSection()) {
45     ns.GetLink("vndk_product")
46         .AddSharedLib(Var("VNDK_SAMEPROCESS_LIBRARIES_PRODUCT"));
47   } else {
48     ns.GetLink("vndk").AddSharedLib({Var("VNDK_SAMEPROCESS_LIBRARIES_PRODUCT"),
49                                      Var("VNDK_CORE_LIBRARIES_PRODUCT")});
50     if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
51       ns.GetLink("vndk_in_system")
52           .AddSharedLib(Var("VNDK_USING_CORE_VARIANT_LIBRARIES"));
53     }
54   }
55   ns.AddRequires(ctx.GetProductRequireLibs());
56   ns.AddProvides(ctx.GetProductProvideLibs());
57   return ns;
58 }
59 }  // namespace contents
60 }  // namespace linkerconfig
61 }  // namespace android
62