diff options
author | Yiwei Zhang <zzyiwei@google.com> | 2020-05-11 03:34:05 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-05-11 03:34:05 +0000 |
commit | d61727ed1113fb3e84876c589a125a190696e14d (patch) | |
tree | 0b45fa8188aa4a55a7779dab39870dda86ed624d | |
parent | 804302c7c021ec8c240ec4fbef3acce84f2e4d39 (diff) | |
parent | 8da3a9d92f72a961686550ad74911ec9d76bd2e2 (diff) | |
download | linkerconfig-d61727ed1113fb3e84876c589a125a190696e14d.tar.gz |
Add sphal and vndk namespaces to unrestricted am: 8da3a9d92f
Change-Id: I3219d6ceb42302e38bc66f73dfbd4c2112eccdf5
-rw-r--r-- | contents/context/context.cc | 4 | ||||
-rw-r--r-- | contents/include/linkerconfig/context.h | 4 | ||||
-rw-r--r-- | contents/namespace/sphal.cc | 4 | ||||
-rw-r--r-- | contents/namespace/vndk.cc | 25 | ||||
-rw-r--r-- | contents/section/unrestricted.cc | 6 |
5 files changed, 30 insertions, 13 deletions
diff --git a/contents/context/context.cc b/contents/context/context.cc index 3ec30a4..7281c57 100644 --- a/contents/context/context.cc +++ b/contents/context/context.cc @@ -42,6 +42,10 @@ bool Context::IsProductSection() const { return current_section_ == SectionType::Product; } +bool Context::IsUnrestrictedSection() const { + return current_section_ == SectionType::Unrestricted; +} + bool Context::IsDefaultConfig() const { return current_linkerconfig_type_ == LinkerConfigType::Default; } diff --git a/contents/include/linkerconfig/context.h b/contents/include/linkerconfig/context.h index 02b1d96..6eb1de1 100644 --- a/contents/include/linkerconfig/context.h +++ b/contents/include/linkerconfig/context.h @@ -34,6 +34,7 @@ enum class SectionType { System, Vendor, Product, + Unrestricted, Other, }; @@ -54,6 +55,7 @@ class Context : public modules::BaseContext { bool IsSystemSection() const; bool IsVendorSection() const; bool IsProductSection() const; + bool IsUnrestrictedSection() const; bool IsDefaultConfig() const; bool IsLegacyConfig() const; @@ -88,4 +90,4 @@ std::string Var(const std::string& name, const std::string& default_value); } // namespace contents } // namespace linkerconfig -} // namespace android
\ No newline at end of file +} // namespace android diff --git a/contents/namespace/sphal.cc b/contents/namespace/sphal.cc index 2627788..70a8c2a 100644 --- a/contents/namespace/sphal.cc +++ b/contents/namespace/sphal.cc @@ -63,7 +63,9 @@ Namespace BuildSphalNamespace([[maybe_unused]] const Context& ctx) { // Only libs listed here can be used. Order is important here as the // namespaces are tried in this order. rs should be before vndk because both // are capable of loading libRS_internal.so - ns.GetLink("rs").AddSharedLib("libRS_internal.so"); + if (ctx.IsSystemSection()) { + ns.GetLink("rs").AddSharedLib("libRS_internal.so"); + } ns.GetLink(ctx.GetSystemNamespaceName()) .AddSharedLib(Var("LLNDK_LIBRARIES_VENDOR", "")); ns.GetLink("vndk").AddSharedLib( diff --git a/contents/namespace/vndk.cc b/contents/namespace/vndk.cc index ef390b8..452abb1 100644 --- a/contents/namespace/vndk.cc +++ b/contents/namespace/vndk.cc @@ -27,25 +27,29 @@ namespace linkerconfig { namespace contents { Namespace BuildVndkNamespace([[maybe_unused]] const Context& ctx, VndkUserPartition vndk_user) { - bool is_system_section = ctx.IsSystemSection() || ctx.IsApexBinaryConfig(); + bool is_system_or_unrestricted_section = ctx.IsSystemSection() || + ctx.IsApexBinaryConfig() || + ctx.IsUnrestrictedSection(); bool is_vndklite = ctx.IsVndkliteConfig(); // In the system section, we need to have an additional vndk namespace for // product apps. We must have a different name "vndk_product" for this // namespace. "vndk_product" namespace is used only from the native_loader for // product apps. const char* name; - if (is_system_section && vndk_user == VndkUserPartition::Product) { + if (is_system_or_unrestricted_section && + vndk_user == VndkUserPartition::Product) { name = "vndk_product"; } else { name = "vndk"; } - // Isolated but visible when used in the [system] section to allow links to be - // created at runtime, e.g. through android_link_namespaces in - // libnativeloader. Otherwise it isn't isolated, so visibility doesn't matter. + // Isolated but visible when used in the [system] or [unrestricted] section to + // allow links to be created at runtime, e.g. through android_link_namespaces + // in libnativeloader. Otherwise it isn't isolated, so visibility doesn't + // matter. Namespace ns(name, - /*is_isolated=*/is_system_section, - /*is_visible=*/is_system_section); + /*is_isolated=*/is_system_or_unrestricted_section, + /*is_visible=*/is_system_or_unrestricted_section); std::vector<std::string> lib_paths; std::vector<std::string> vndk_paths; @@ -61,14 +65,15 @@ Namespace BuildVndkNamespace([[maybe_unused]] const Context& ctx, for (const auto& lib_path : lib_paths) { ns.AddSearchPath(lib_path + "vndk-sp", AsanPath::WITH_DATA_ASAN); - if (!is_system_section) { + if (!is_system_or_unrestricted_section) { ns.AddSearchPath(lib_path + "vndk", AsanPath::WITH_DATA_ASAN); } } ns.AddSearchPath("/apex/com.android.vndk.v" + vndk_version + "/${LIB}", AsanPath::SAME_PATH); - if (is_system_section && vndk_user == VndkUserPartition::Vendor) { + if (is_system_or_unrestricted_section && + vndk_user == VndkUserPartition::Vendor) { // It is for vendor sp-hal ns.AddPermittedPath("/odm/${LIB}/hw", AsanPath::WITH_DATA_ASAN); ns.AddPermittedPath("/odm/${LIB}/egl", AsanPath::WITH_DATA_ASAN); @@ -96,7 +101,7 @@ Namespace BuildVndkNamespace([[maybe_unused]] const Context& ctx, } if (!is_vndklite) { - if (is_system_section) { + if (is_system_or_unrestricted_section) { if (vndk_user == VndkUserPartition::Vendor) { // The "vndk" namespace links to the system namespace for LLNDK libs above // and links to "sphal" namespace for vendor libs. The ordering matters; diff --git a/contents/section/unrestricted.cc b/contents/section/unrestricted.cc index ce6dcbd..ea1af8d 100644 --- a/contents/section/unrestricted.cc +++ b/contents/section/unrestricted.cc @@ -34,10 +34,14 @@ namespace android { namespace linkerconfig { namespace contents { Section BuildUnrestrictedSection(Context& ctx) { - ctx.SetCurrentSection(SectionType::Other); + ctx.SetCurrentSection(SectionType::Unrestricted); std::vector<Namespace> namespaces; namespaces.emplace_back(BuildUnrestrictedDefaultNamespace(ctx)); + if (ctx.IsVndkAvailable()) { + namespaces.emplace_back(BuildSphalNamespace(ctx)); + namespaces.emplace_back(BuildVndkNamespace(ctx, VndkUserPartition::Vendor)); + } return BuildSection(ctx, "unrestricted", |