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 #include "linkerconfig/common.h"
18 #include "linkerconfig/context.h"
19 #include "linkerconfig/environment.h"
20 #include "linkerconfig/namespacebuilder.h"
21 #include "linkerconfig/section.h"
22 #include "linkerconfig/sectionbuilder.h"
23
24 using android::linkerconfig::contents::SectionType;
25 using android::linkerconfig::modules::Namespace;
26 using android::linkerconfig::modules::Section;
27
28 namespace android {
29 namespace linkerconfig {
30 namespace contents {
BuildSystemSection(Context & ctx)31 Section BuildSystemSection(Context& ctx) {
32 ctx.SetCurrentSection(SectionType::System);
33 std::vector<Namespace> namespaces;
34
35 namespaces.emplace_back(BuildSystemDefaultNamespace(ctx));
36 if (ctx.IsVndkAvailable()) {
37 namespaces.emplace_back(BuildSphalNamespace(ctx));
38 namespaces.emplace_back(BuildRsNamespace(ctx));
39 namespaces.emplace_back(BuildVndkNamespace(ctx, VndkUserPartition::Vendor));
40 if (android::linkerconfig::modules::IsProductVndkVersionDefined()) {
41 namespaces.emplace_back(
42 BuildVndkNamespace(ctx, VndkUserPartition::Product));
43 }
44 }
45
46 std::set<std::string> visible_apexes{
47 "com.android.art",
48 "com.android.i18n",
49 "com.android.neuralnetworks",
50 "com.android.runtime",
51 "com.android.media",
52 "com.android.conscrypt",
53 "com.android.os.statsd",
54 };
55
56 // APEXes with JNI libs should be visible
57 for (const auto& apex : ctx.GetApexModules()) {
58 if (apex.jni_libs.size() > 0) {
59 visible_apexes.insert(apex.name);
60 }
61 }
62
63 return BuildSection(ctx, "system", std::move(namespaces), visible_apexes);
64 }
65 } // namespace contents
66 } // namespace linkerconfig
67 } // namespace android
68