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 // Linker config for native tests that need access to both system and vendor 18 // libraries. This replicates the default linker config (done by 19 // init_default_namespace_no_config in bionic/linker/linker.cpp), except that it 20 // includes the requisite namespace setup for APEXes. 21 22 #include "linkerconfig/sectionbuilder.h" 23 24 #include "linkerconfig/common.h" 25 #include "linkerconfig/environment.h" 26 #include "linkerconfig/namespacebuilder.h" 27 #include "linkerconfig/section.h" 28 29 using android::linkerconfig::contents::SectionType; 30 using android::linkerconfig::modules::Namespace; 31 using android::linkerconfig::modules::Section; 32 33 namespace android { 34 namespace linkerconfig { 35 namespace contents { BuildUnrestrictedSection(Context & ctx)36Section BuildUnrestrictedSection(Context& ctx) { 37 ctx.SetCurrentSection(SectionType::Unrestricted); 38 std::vector<Namespace> namespaces; 39 40 namespaces.emplace_back(BuildUnrestrictedDefaultNamespace(ctx)); 41 if (android::linkerconfig::modules::IsTreblelizedDevice()) { 42 namespaces.emplace_back(BuildSphalNamespace(ctx)); 43 if (android::linkerconfig::modules::IsVendorVndkVersionDefined()) { 44 namespaces.emplace_back(BuildVndkNamespace(ctx, VndkUserPartition::Vendor)); 45 } 46 namespaces.emplace_back(BuildRsNamespace(ctx)); 47 } 48 49 std::set<std::string> visible_apexes; 50 51 // APEXes with JNI libs or public libs should be visible 52 for (const auto& apex : ctx.GetApexModules()) { 53 if (apex.jni_libs.size() > 0 || apex.public_libs.size() > 0) { 54 visible_apexes.insert(apex.name); 55 } 56 } 57 58 return BuildSection( 59 ctx, "unrestricted", std::move(namespaces), visible_apexes); 60 } 61 } // namespace contents 62 } // namespace linkerconfig 63 } // namespace android 64