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 namespace is where no-vendor-variant VNDK libraries are loaded for a
18 // vendor process. Note that we do not simply export these libraries from the
19 // "system" namespace, because in some cases both the core variant and the
20 // vendor variant of a VNDK library may be loaded. In such cases, we do not
21 // want to eliminate double-loading because doing so means the global states
22 // of the library would be shared.
23 //
24 // Only the no-vendor-variant VNDK libraries are allowed in this namespace.
25 // This is to ensure that we do not load libraries needed by no-vendor-variant
26 // VNDK libraries into vndk_in_system namespace.
27
28 #include "linkerconfig/namespacebuilder.h"
29
30 #include <android-base/strings.h>
31
32 #include "linkerconfig/environment.h"
33
34 using android::linkerconfig::modules::Namespace;
35
36 namespace android {
37 namespace linkerconfig {
38 namespace contents {
BuildVndkInSystemNamespace(const Context & ctx)39 Namespace BuildVndkInSystemNamespace([[maybe_unused]] const Context& ctx) {
40 Namespace ns("vndk_in_system",
41 /*is_isolated=*/true,
42 /*is_visible=*/false);
43
44 // The search paths here should be kept the same as that of the 'system' namespace.
45 ns.AddSearchPath("/system/${LIB}");
46 ns.AddSearchPath(Var("SYSTEM_EXT") + "/${LIB}");
47
48 if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
49 ns.AddAllowedLib(Var("VNDK_USING_CORE_VARIANT_LIBRARIES"));
50 }
51
52 AddLlndkLibraries(ctx,
53 &ns,
54 ctx.IsProductSection() ? VndkUserPartition::Product
55 : VndkUserPartition::Vendor);
56 ns.GetLink("vndk").AllowAllSharedLibs();
57
58 if (ctx.IsVendorSection() || ctx.IsProductSection()) {
59 ns.GetLink("default").AllowAllSharedLibs();
60 }
61
62 return ns;
63 }
64 } // namespace contents
65 } // namespace linkerconfig
66 } // namespace android
67