blob: 7241861d94aa2562a384c817b9d25402c3908057 [file] [log] [blame]
Kiyoung Kimff9cbf72019-03-14 18:26:24 +09001/*
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/namespacebuilder.h"
18
19#include "linkerconfig/environment.h"
20
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090021using android::linkerconfig::modules::Namespace;
22
23namespace android {
24namespace linkerconfig {
25namespace contents {
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090026Namespace BuildVndkNamespace([[maybe_unused]] const Context& ctx) {
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090027 bool is_system_section = ctx.IsSystemSection();
Kiyoung Kimac298bb2019-08-07 19:13:09 +090028 Namespace ns("vndk",
29 /*is_isolated=*/is_system_section,
30 /*is_visible=*/is_system_section);
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090031
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090032 ns.AddSearchPath("/odm/${LIB}/vndk-sp", /*also_in_asan=*/true,
33 /*with_data_asan=*/true);
34 ns.AddSearchPath("/vendor/${LIB}/vndk-sp", /*also_in_asan=*/true,
35 /*with_data_asan=*/true);
Kiyoung Kim853438d2019-07-16 09:51:14 +090036 ns.AddSearchPath("/system/${LIB}/vndk-sp-@{VNDK_VER}", /*also_in_asan=*/true,
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090037 /*with_data_asan=*/true);
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090038
39 if (!is_system_section) {
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090040 ns.AddSearchPath("/odm/${LIB}/vndk", /*also_in_asan=*/true,
41 /*with_data_asan=*/true);
42 ns.AddSearchPath("/vendor/${LIB}/vndk", /*also_in_asan=*/true,
43 /*with_data_asan=*/true);
Kiyoung Kim853438d2019-07-16 09:51:14 +090044 ns.AddSearchPath("/system/${LIB}/vndk-@{VNDK_VER}", /*also_in_asan=*/true,
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090045 /*with_data_asan=*/true);
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090046 }
47
48 if (is_system_section) {
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090049 ns.AddPermittedPath("/odm/${LIB}/hw", /*also_in_asan=*/true,
50 /*with_data_asan=*/true);
51 ns.AddPermittedPath("/odm/${LIB}/egl", /*also_in_asan=*/true,
52 /*with_data_asan=*/true);
53 ns.AddPermittedPath("/vendor/${LIB}/hw", /*also_in_asan=*/true,
54 /*with_data_asan=*/true);
55 ns.AddPermittedPath("/vendor/${LIB}/egl", /*also_in_asan=*/true,
56 /*with_data_asan=*/true);
57 ns.AddPermittedPath("/system/vendor/${LIB}/hw", /*also_in_asan=*/false,
58 /*with_data_asan=*/false);
59 ns.AddPermittedPath("/system/vendor/${LIB}/egl", /*also_in_asan=*/false,
60 /*with_data_asan=*/false);
Kiyoung Kim853438d2019-07-16 09:51:14 +090061 ns.AddPermittedPath("/system/${LIB}/vndk-sp-@{VNDK_VER}/hw",
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090062 /*also_in_asan=*/true, /*with_data_asan=*/true);
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090063 }
64
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090065 ns.CreateLink(is_system_section ? "default" : "system")
66 .AddSharedLib({"@{LLNDK_LIBRARIES}", "@{SANITIZER_RUNTIME_LIBRARIES}"});
Kiyoung Kimac298bb2019-08-07 19:13:09 +090067 ns.CreateLink("runtime").AddSharedLib("@{SANITIZER_RUNTIME_LIBRARIES}");
68
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090069 if (is_system_section) {
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090070 ns.CreateLink("sphal", true);
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090071 } else {
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090072 ns.CreateLink("default", true);
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090073
74 if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
Kiyoung Kim7a0d9fb2019-05-09 14:03:43 +090075 ns.CreateLink("vndk_in_system")
76 .AddSharedLib("@{VNDK_USING_CORE_VARIANT_LIBRARIES");
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090077 }
78 }
79
Kiyoung Kimac298bb2019-08-07 19:13:09 +090080 ns.CreateLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
81
Kiyoung Kimff9cbf72019-03-14 18:26:24 +090082 return ns;
83}
84} // namespace contents
85} // namespace linkerconfig
86} // namespace android