Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 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/namespacebuilder.h" |
| 18 | |
| 19 | #include "linkerconfig/environment.h" |
| 20 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 21 | using android::linkerconfig::modules::Namespace; |
| 22 | |
| 23 | namespace android { |
| 24 | namespace linkerconfig { |
| 25 | namespace contents { |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 26 | Namespace BuildVndkNamespace([[maybe_unused]] const Context& ctx) { |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 27 | bool is_system_section = ctx.IsSystemSection(); |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame^] | 28 | Namespace ns("vndk", |
| 29 | /*is_isolated=*/is_system_section, |
| 30 | /*is_visible=*/is_system_section); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 31 | |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 32 | 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 Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 36 | ns.AddSearchPath("/system/${LIB}/vndk-sp-@{VNDK_VER}", /*also_in_asan=*/true, |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 37 | /*with_data_asan=*/true); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 38 | |
| 39 | if (!is_system_section) { |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 40 | 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 Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 44 | ns.AddSearchPath("/system/${LIB}/vndk-@{VNDK_VER}", /*also_in_asan=*/true, |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 45 | /*with_data_asan=*/true); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | if (is_system_section) { |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 49 | 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 Kim | 853438d | 2019-07-16 09:51:14 +0900 | [diff] [blame] | 61 | ns.AddPermittedPath("/system/${LIB}/vndk-sp-@{VNDK_VER}/hw", |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 62 | /*also_in_asan=*/true, /*with_data_asan=*/true); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 63 | } |
| 64 | |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 65 | ns.CreateLink(is_system_section ? "default" : "system") |
| 66 | .AddSharedLib({"@{LLNDK_LIBRARIES}", "@{SANITIZER_RUNTIME_LIBRARIES}"}); |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame^] | 67 | ns.CreateLink("runtime").AddSharedLib("@{SANITIZER_RUNTIME_LIBRARIES}"); |
| 68 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 69 | if (is_system_section) { |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 70 | ns.CreateLink("sphal", true); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 71 | } else { |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 72 | ns.CreateLink("default", true); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 73 | |
| 74 | if (android::linkerconfig::modules::IsVndkInSystemNamespace()) { |
Kiyoung Kim | 7a0d9fb | 2019-05-09 14:03:43 +0900 | [diff] [blame] | 75 | ns.CreateLink("vndk_in_system") |
| 76 | .AddSharedLib("@{VNDK_USING_CORE_VARIANT_LIBRARIES"); |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 77 | } |
| 78 | } |
| 79 | |
Kiyoung Kim | ac298bb | 2019-08-07 19:13:09 +0900 | [diff] [blame^] | 80 | ns.CreateLink("neuralnetworks").AddSharedLib("libneuralnetworks.so"); |
| 81 | |
Kiyoung Kim | ff9cbf7 | 2019-03-14 18:26:24 +0900 | [diff] [blame] | 82 | return ns; |
| 83 | } |
| 84 | } // namespace contents |
| 85 | } // namespace linkerconfig |
| 86 | } // namespace android |