diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-02-15 10:30:30 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-02-15 10:30:30 +0000 |
commit | 8a21670091c6f1d1ea2bb8a901a8ef92965c03f0 (patch) | |
tree | 8487ad79aa61cf032ae85734aebb4b4eb95f712a | |
parent | 4b693fbbf7de0bab5e8e9abf7be400429107da82 (diff) | |
parent | 80f50eed84af2422b42541b4b5fdd867d6ce9541 (diff) | |
download | linkerconfig-8a21670091c6f1d1ea2bb8a901a8ef92965c03f0.tar.gz |
Merge changes I555f71b4,I7de92572 into main
* changes:
Make WriteConfig methods const
doc: added a section about public.libraries.txt
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | contents/configuration/baseconfig.cc | 2 | ||||
-rw-r--r-- | modules/configuration.cc | 2 | ||||
-rw-r--r-- | modules/include/linkerconfig/configuration.h | 2 | ||||
-rw-r--r-- | modules/include/linkerconfig/namespace.h | 4 | ||||
-rw-r--r-- | modules/include/linkerconfig/section.h | 2 | ||||
-rw-r--r-- | modules/namespace.cc | 4 | ||||
-rw-r--r-- | modules/section.cc | 22 |
8 files changed, 27 insertions, 19 deletions
@@ -57,6 +57,14 @@ linker.config.json file is in json format which can contain properties as below. } ``` +### public.libraries.txt + +`linkerconfig` reads both `/system/etc/public.libraries.txt` and `/vendor/etc/public.libraries.txt` to identify +libraries that are provided by APEX and accessible from apps via `libnativeloader`. + +`linkerconfig` generates `apex.libraries.config.txt` file which lists public libraries provided APEX. `libnativeloader`, then, +links those libraries from classloader-namespace to providing APEXes. + ## Outputs ### /linkerconfig/ld.config.txt & /linkerconfig/*/ld.config.txt diff --git a/contents/configuration/baseconfig.cc b/contents/configuration/baseconfig.cc index 727270c..7f6a9c8 100644 --- a/contents/configuration/baseconfig.cc +++ b/contents/configuration/baseconfig.cc @@ -112,7 +112,7 @@ android::linkerconfig::modules::Configuration CreateBaseConfiguration( sections.emplace_back(BuildFuzzSection(ctx)); return android::linkerconfig::modules::Configuration(std::move(sections), - dirToSection); + std::move(dirToSection)); } } // namespace contents } // namespace linkerconfig diff --git a/modules/configuration.cc b/modules/configuration.cc index fdb0d16..4a08844 100644 --- a/modules/configuration.cc +++ b/modules/configuration.cc @@ -24,7 +24,7 @@ namespace android { namespace linkerconfig { namespace modules { -void Configuration::WriteConfig(ConfigWriter& writer) { +void Configuration::WriteConfig(ConfigWriter& writer) const { std::unordered_map<std::string, std::string> resolved_dirs; for (const auto& [dir, section] : dir_to_section_list_) { diff --git a/modules/include/linkerconfig/configuration.h b/modules/include/linkerconfig/configuration.h index e264f99..2e010cb 100644 --- a/modules/include/linkerconfig/configuration.h +++ b/modules/include/linkerconfig/configuration.h @@ -37,7 +37,7 @@ class Configuration { Configuration(const Configuration&) = delete; Configuration(Configuration&&) = default; - void WriteConfig(ConfigWriter& writer); + void WriteConfig(ConfigWriter& writer) const; // For test usage Section* GetSection(const std::string& name); diff --git a/modules/include/linkerconfig/namespace.h b/modules/include/linkerconfig/namespace.h index d8ea9d5..bd6d6f9 100644 --- a/modules/include/linkerconfig/namespace.h +++ b/modules/include/linkerconfig/namespace.h @@ -57,7 +57,7 @@ class Namespace { // it is returned, otherwise one is created and pushed back to tail. Link& GetLink(const std::string& target_namespace); - void WriteConfig(ConfigWriter& writer); + void WriteConfig(ConfigWriter& writer) const; void AddAllowedLib(const std::string& path); std::string GetName() const; @@ -128,7 +128,7 @@ class Namespace { const std::vector<std::string>& path_list); bool RequiresAsanPath(const std::string& path); const std::string CreateAsanPath(const std::string& path); - android::base::Result<void> VerifyContents(); + android::base::Result<void> VerifyContents() const; }; void InitializeWithApex(Namespace& ns, const ApexInfo& apex_info); diff --git a/modules/include/linkerconfig/section.h b/modules/include/linkerconfig/section.h index 730392c..7088e5c 100644 --- a/modules/include/linkerconfig/section.h +++ b/modules/include/linkerconfig/section.h @@ -76,7 +76,7 @@ class Section { Section(const Section&) = delete; Section(Section&&) = default; - void WriteConfig(ConfigWriter& writer); + void WriteConfig(ConfigWriter& writer) const; std::vector<std::string> GetBinaryPaths(); std::string GetName(); diff --git a/modules/namespace.cc b/modules/namespace.cc index bc675db..dd9ae52 100644 --- a/modules/namespace.cc +++ b/modules/namespace.cc @@ -90,7 +90,7 @@ Link& Namespace::GetLink(const std::string& target_namespace) { return links_.emplace_back(name_, target_namespace); } -void Namespace::WriteConfig(ConfigWriter& writer) { +void Namespace::WriteConfig(ConfigWriter& writer) const { auto verify_result = VerifyContents(); if (!verify_result.ok()) { LOG(ERROR) << "Namespace " << name_ @@ -169,7 +169,7 @@ const std::string Namespace::CreateAsanPath(const std::string& path) { return kDataAsanPath + path; } -Result<void> Namespace::VerifyContents() { +Result<void> Namespace::VerifyContents() const { auto apex_with_all_shared_link = VerifyIfApexNamespaceContainsAllSharedLink(*this); if (!apex_with_all_shared_link.ok()) { diff --git a/modules/section.cc b/modules/section.cc index c30f931..35d66b8 100644 --- a/modules/section.cc +++ b/modules/section.cc @@ -33,18 +33,9 @@ namespace android { namespace linkerconfig { namespace modules { -void Section::WriteConfig(ConfigWriter& writer) { +void Section::WriteConfig(ConfigWriter& writer) const { writer.WriteLine("[" + name_ + "]"); - std::sort(namespaces_.begin(), - namespaces_.end(), - [](const auto& lhs, const auto& rhs) -> bool { - // make "default" a smallest one - if (lhs.GetName() == "default") return true; - if (rhs.GetName() == "default") return false; - return lhs.GetName() < rhs.GetName(); - }); - if (namespaces_.size() > 1) { std::vector<std::string> additional_namespaces; for (const auto& ns : namespaces_) { @@ -56,7 +47,7 @@ void Section::WriteConfig(ConfigWriter& writer) { Join(additional_namespaces, ',')); } - for (auto& ns : namespaces_) { + for (const auto& ns : namespaces_) { ns.WriteConfig(writer); } } @@ -160,6 +151,15 @@ void Section::Resolve(const BaseContext& ctx, } iter++; } while (iter != namespaces_.end()); + + std::sort(namespaces_.begin(), + namespaces_.end(), + [](const auto& lhs, const auto& rhs) -> bool { + // make "default" a smallest one + if (lhs.GetName() == "default") return true; + if (rhs.GetName() == "default") return false; + return lhs.GetName() < rhs.GetName(); + }); } Namespace* Section::GetNamespace(const std::string& namespace_name) { |