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 <android-base/strings.h>
23
24 #include "linkerconfig/common.h"
25 #include "linkerconfig/environment.h"
26
27 using android::linkerconfig::modules::Namespace;
28
29 namespace android {
30 namespace linkerconfig {
31 namespace contents {
BuildVendorDefaultNamespace(const Context & ctx)32 Namespace BuildVendorDefaultNamespace(const Context& ctx) {
33 return BuildVendorNamespace(ctx, "default");
34 }
35
BuildVendorNamespace(const Context & ctx,const std::string & name)36 Namespace BuildVendorNamespace([[maybe_unused]] const Context& ctx,
37 const std::string& name) {
38 Namespace ns(name, /*is_isolated=*/true, /*is_visible=*/true);
39
40 ns.AddSearchPath("/odm/${LIB}");
41 ns.AddSearchPath("/vendor/${LIB}");
42 ns.AddSearchPath("/vendor/${LIB}/hw");
43 ns.AddSearchPath("/vendor/${LIB}/egl");
44
45 ns.AddPermittedPath("/odm");
46 ns.AddPermittedPath("/vendor");
47 ns.AddPermittedPath("/system/vendor");
48
49 if (ctx.IsVndkAvailable()) {
50 ns.GetLink("rs").AddSharedLib("libRS_internal.so");
51 ns.AddRequires(base::Split(Var("LLNDK_LIBRARIES_VENDOR", ""), ":"));
52 ns.GetLink(ctx.GetSystemNamespaceName())
53 .AddSharedLib(Var("SANITIZER_DEFAULT_VENDOR"));
54 ns.GetLink("vndk").AddSharedLib({Var("VNDK_SAMEPROCESS_LIBRARIES_VENDOR"),
55 Var("VNDK_CORE_LIBRARIES_VENDOR")});
56 if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
57 ns.GetLink("vndk_in_system")
58 .AddSharedLib(Var("VNDK_USING_CORE_VARIANT_LIBRARIES"));
59 }
60 }
61
62 ns.AddRequires(ctx.GetVendorRequireLibs());
63 ns.AddProvides(ctx.GetVendorProvideLibs());
64 return ns;
65 }
66 } // namespace contents
67 } // namespace linkerconfig
68 } // namespace android
69