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 if (android::linkerconfig::modules::IsProductVndkVersionDefined()) {
43 ns.GetLink(ctx.GetSystemNamespaceName())
44 .AddSharedLib(Var("SANITIZER_DEFAULT_PRODUCT"));
45 if (ctx.IsSystemSection() || ctx.IsUnrestrictedSection()) {
46 ns.GetLink("vndk_product")
47 .AddSharedLib(Var("VNDK_SAMEPROCESS_LIBRARIES_PRODUCT"));
48 } else {
49 ns.GetLink("vndk").AddSharedLib(
50 {Var("VNDK_SAMEPROCESS_LIBRARIES_PRODUCT"),
51 Var("VNDK_CORE_LIBRARIES_PRODUCT")});
52 if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
53 ns.GetLink("vndk_in_system")
54 .AddSharedLib(Var("VNDK_USING_CORE_VARIANT_LIBRARIES"));
55 }
56 }
57 }
58 ns.AddRequires(ctx.GetProductRequireLibs());
59 ns.AddProvides(ctx.GetProductProvideLibs());
60 return ns;
61 }
62 } // namespace contents
63 } // namespace linkerconfig
64 } // namespace android
65