Snap for 6439596 from 729bc5978e09f803c12e26e377f18bd022166cc7 to qt-aml-tzdata-release
Change-Id: I8551ed1f6d6b9ee44f7cd2e613c0c26e32f58308
diff --git a/.clang-format b/.clang-format
index 5023f2c..175c5dd 100644
--- a/.clang-format
+++ b/.clang-format
@@ -8,7 +8,4 @@
PointerAlignment: Left
TabWidth: 2
UseTab: Never
-PenaltyExcessCharacter: 32
-
-BinPackArguments: false
-AllowAllParametersOfDeclarationOnNextLine: false
\ No newline at end of file
+PenaltyExcessCharacter: 32
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
index d7ef173..02f3857 100644
--- a/Android.bp
+++ b/Android.bp
@@ -25,122 +25,34 @@
"libbase",
"liblog",
],
- host_supported: true,
+ header_libs: ["linkerconfig_headers"],
}
-cc_defaults {
- name: "linkerconfig_test_defaults",
- defaults: ["linkerconfig_defaults"],
- cflags: [
- "-g",
- "-Wunused",
- ],
- test_suites: ["general-tests"],
+cc_library_headers {
+ name: "linkerconfig_headers",
+ export_include_dirs: ["include"],
}
cc_library_static {
name: "linkerconfig_modules",
defaults: [ "linkerconfig_defaults" ],
- export_include_dirs: [ "modules/include" ],
srcs: [
"modules/*.cc",
],
}
-cc_library_static {
- name: "linkerconfig_contents",
- defaults: [ "linkerconfig_defaults" ],
- export_include_dirs: [ "contents/include" ],
- static_libs: [
- "linkerconfig_modules",
- ],
- srcs: [
- "contents/namespace/*.cc",
- "contents/section/*.cc",
- "contents/configuration/*.cc",
- "contents/context/*.cc",
- "contents/common/*.cc",
- ],
-}
-
-cc_library_static {
- name: "linkerconfig_generator",
- defaults : [ "linkerconfig_defaults" ],
- export_include_dirs: [ "generator/include" ],
- static_libs: [
- "linkerconfig_modules",
- "linkerconfig_contents",
- "libc++fs",
- ],
- srcs: [
- "generator/*.cc",
- ],
-}
-
-cc_binary {
- name: "linkerconfig",
- defaults: [ "linkerconfig_defaults" ],
- static_libs: [
- "linkerconfig_modules",
- "linkerconfig_contents",
- "linkerconfig_generator",
- ],
- srcs: [
- "main.cc",
- ],
- static_executable: true,
-}
-
cc_test {
name: "linkerconfig_modules_unittest",
- defaults: [ "linkerconfig_test_defaults" ],
+ defaults: [ "linkerconfig_defaults" ],
srcs: [
"modules/tests/*_test.cc",
],
static_libs: [
"linkerconfig_modules",
],
-}
-
-cc_test {
- name: "linkerconfig_backward_compatibility_test",
- defaults: [ "linkerconfig_test_defaults" ],
- srcs: [
- "contents/tests/backward_compatibility/*_test.cc",
+ cflags: [
+ "-g",
+ "-Wunused",
],
- static_libs: [
- "linkerconfig_modules",
- "linkerconfig_contents",
- ],
-}
-
-cc_test {
- name: "linkerconfig_generator_unittest",
- defaults: [ "linkerconfig_test_defaults" ],
- srcs: [
- "generator/tests/*_test.cc",
- ],
- static_libs: [
- "linkerconfig_modules",
- "linkerconfig_contents",
- "linkerconfig_generator",
- ],
- data: [
- "generator/tests/data/*.txt",
- ],
-}
-
-cc_test {
- name: "linkerconfig_contents_fulltest",
- defaults: [ "linkerconfig_test_defaults" ],
- local_include_dirs: [
- "contents/tests/configuration/include",
- ],
- srcs: [
- "contents/tests/configuration/*_test.cc",
- ],
- static_libs: [
- "linkerconfig_modules",
- "linkerconfig_contents",
- ],
-}
+ test_suites: ["general-tests"],
+}
\ No newline at end of file
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 82cfd3b..18361d9 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -2,15 +2,6 @@
"presubmit": [
{
"name": "linkerconfig_modules_unittest"
- },
- {
- "name" : "linkerconfig_backward_compatibility_test"
- },
- {
- "name" : "linkerconfig_contents_fulltest"
- },
- {
- "name" : "linkerconfig_generator_unittest"
}
]
}
\ No newline at end of file
diff --git a/contents/common/system_links.cc b/contents/common/system_links.cc
deleted file mode 100644
index 27ba013..0000000
--- a/contents/common/system_links.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/common.h"
-
-#include <string>
-
-#include "linkerconfig/context.h"
-#include "linkerconfig/section.h"
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-
-using android::linkerconfig::modules::Namespace;
-using android::linkerconfig::modules::Section;
-
-void AddStandardSystemLinks(const Context& ctx, Section* section) {
- std::string system_ns_name = ctx.GetSystemNamespaceName();
- section->ForEachNamespaces([system_ns_name](Namespace& ns) {
- if (ns.GetName() != system_ns_name) {
- ns.GetLink(system_ns_name)
- .AddSharedLib({"libc.so",
- "libm.so",
- "libdl.so",
- "@{SANITIZER_RUNTIME_LIBRARIES}"});
- }
- });
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/configuration/baseconfig.cc b/contents/configuration/baseconfig.cc
deleted file mode 100644
index eca4d31..0000000
--- a/contents/configuration/baseconfig.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/baseconfig.h"
-#include "linkerconfig/environment.h"
-#include "linkerconfig/sectionbuilder.h"
-
-using android::linkerconfig::modules::DirToSection;
-using android::linkerconfig::modules::Section;
-
-namespace {
-const std::vector<DirToSection> kDirToSection = {
- {"/system/bin/", "system"},
- {"/system/xbin/", "system"},
- {"/@{SYSTEM_EXT:system_ext}/bin/", "system"},
- {"/@{PRODUCT:product}/bin/", "system"},
-
- {"/odm/bin/", "vendor"},
- {"/vendor/bin/", "vendor"},
- {"/data/nativetest/odm", "vendor"},
- {"/data/nativetest64/odm", "vendor"},
- {"/data/benchmarktest/odm", "vendor"},
- {"/data/benchmarktest64/odm", "vendor"},
- {"/data/nativetest/vendor", "vendor"},
- {"/data/nativetest64/vendor", "vendor"},
- {"/data/benchmarktest/vendor", "vendor"},
- {"/data/benchmarktest64/vendor", "vendor"},
-
- {"/data/nativetest/unrestricted", "unrestricted"},
- {"/data/nativetest64/unrestricted", "unrestricted"},
-
- // TODO(b/123864775): Ensure tests are run from /data/nativetest{,64} or (if
- // necessary) the unrestricted subdirs above. Then clean this up.
- {"/data/local/tmp", "unrestricted"},
-
- {"/postinstall", "postinstall"},
- // Fallback entry to provide APEX namespace lookups for binaries anywhere
- // else. This must be last.
- {"/data", "system"},
-};
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-android::linkerconfig::modules::Configuration CreateBaseConfiguration() {
- std::vector<Section> sections;
-
- Context current_context;
- if (android::linkerconfig::modules::IsVndkLiteDevice()) {
- current_context.SetCurrentLinkerConfigType(LinkerConfigType::Vndklite);
- }
-
- sections.emplace_back(BuildSystemSection(current_context));
- sections.emplace_back(BuildVendorSection(current_context));
- sections.emplace_back(BuildUnrestrictedSection(current_context));
- sections.emplace_back(BuildPostInstallSection(current_context));
-
- return android::linkerconfig::modules::Configuration(std::move(sections),
- kDirToSection);
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/contents/configuration/legacy.cc b/contents/configuration/legacy.cc
deleted file mode 100644
index 70b0c4a..0000000
--- a/contents/configuration/legacy.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/legacy.h"
-#include "linkerconfig/sectionbuilder.h"
-
-using android::linkerconfig::contents::LinkerConfigType;
-using android::linkerconfig::modules::DirToSection;
-using android::linkerconfig::modules::Section;
-
-namespace {
-const std::vector<DirToSection> kDirToSection = {
- // All binaries gets the same configuration 'legacy'
- {"/system", "legacy"},
- {"/@{SYSTEM_EXT:system_ext}", "legacy"},
- {"/@{PRODUCT:product}", "legacy"},
- {"/vendor", "legacy"},
- {"/odm", "legacy"},
- {"/sbin", "legacy"},
- // Except for /postinstall, where only /system and /product are searched
- {"/postinstall", "postinstall"},
- // Fallback entry to provide APEX namespace lookups for binaries anywhere
- // else. This must be last.
- {"/data", "legacy"},
-};
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-android::linkerconfig::modules::Configuration CreateLegacyConfiguration() {
- std::vector<Section> sections;
- Context current_context;
- current_context.SetCurrentLinkerConfigType(LinkerConfigType::Legacy);
-
- sections.emplace_back(BuildLegacySection(current_context));
- sections.emplace_back(BuildPostInstallSection(current_context));
-
- return android::linkerconfig::modules::Configuration(std::move(sections),
- kDirToSection);
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/contents/context/context.cc b/contents/context/context.cc
deleted file mode 100644
index d1535ff..0000000
--- a/contents/context/context.cc
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/context.h"
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-bool Context::IsSystemSection() const {
- return current_section == SectionType::System;
-}
-
-bool Context::IsVendorSection() const {
- return current_section == SectionType::Vendor;
-}
-
-bool Context::IsDefaultConfig() const {
- return current_linkerconfig_type == LinkerConfigType::Default;
-}
-
-bool Context::IsLegacyConfig() const {
- return current_linkerconfig_type == LinkerConfigType::Legacy;
-}
-
-bool Context::IsVndkliteConfig() const {
- return current_linkerconfig_type == LinkerConfigType::Vndklite;
-}
-
-bool Context::IsRecoveryConfig() const {
- return current_linkerconfig_type == LinkerConfigType::Recovery;
-}
-
-void Context::SetCurrentSection(SectionType section_type) {
- current_section = section_type;
-}
-
-std::string Context::GetSystemNamespaceName() const {
- return IsVendorSection() && !IsVndkliteConfig() ? "system" : "default";
-}
-
-void Context::SetCurrentLinkerConfigType(LinkerConfigType config_type) {
- current_linkerconfig_type = config_type;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/include/linkerconfig/baseconfig.h b/contents/include/linkerconfig/baseconfig.h
deleted file mode 100644
index 5aa43fe..0000000
--- a/contents/include/linkerconfig/baseconfig.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "linkerconfig/configuration.h"
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-android::linkerconfig::modules::Configuration CreateBaseConfiguration();
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/contents/include/linkerconfig/common.h b/contents/include/linkerconfig/common.h
deleted file mode 100644
index 9c75d19..0000000
--- a/contents/include/linkerconfig/common.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "linkerconfig/context.h"
-#include "linkerconfig/section.h"
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-
-using android::linkerconfig::modules::Section;
-
-// Adds links from all namespaces in the given section to the namespace for
-// /system/${LIB} for standard libraries like Bionic (libc.so, libm.so,
-// libdl.so) and applicable libclang_rt.*.
-void AddStandardSystemLinks(const Context& ctx, Section* section);
-
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/include/linkerconfig/context.h b/contents/include/linkerconfig/context.h
deleted file mode 100644
index a2c0a7e..0000000
--- a/contents/include/linkerconfig/context.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <string>
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-
-enum class SectionType {
- System,
- Vendor,
- Other,
-};
-
-enum class LinkerConfigType {
- Default,
- Legacy,
- Vndklite,
- Recovery,
-};
-
-class Context {
- public:
- Context()
- : current_section(SectionType::System),
- current_linkerconfig_type(LinkerConfigType::Default) {
- }
- bool IsSystemSection() const;
- bool IsVendorSection() const;
-
- bool IsDefaultConfig() const;
- bool IsLegacyConfig() const;
- bool IsVndkliteConfig() const;
- bool IsRecoveryConfig() const;
-
- void SetCurrentSection(SectionType value);
- void SetCurrentLinkerConfigType(LinkerConfigType value);
-
- // Returns the namespace that covers /system/${LIB}.
- std::string GetSystemNamespaceName() const;
-
- private:
- SectionType current_section;
- LinkerConfigType current_linkerconfig_type;
-};
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/include/linkerconfig/legacy.h b/contents/include/linkerconfig/legacy.h
deleted file mode 100644
index 3a6e9bf..0000000
--- a/contents/include/linkerconfig/legacy.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "linkerconfig/configuration.h"
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-android::linkerconfig::modules::Configuration CreateLegacyConfiguration();
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/contents/include/linkerconfig/namespacebuilder.h b/contents/include/linkerconfig/namespacebuilder.h
deleted file mode 100644
index f582063..0000000
--- a/contents/include/linkerconfig/namespacebuilder.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "linkerconfig/context.h"
-#include "linkerconfig/namespace.h"
-
-typedef android::linkerconfig::modules::Namespace NamespaceBuilder(
- const android::linkerconfig::contents::Context& ctx);
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-NamespaceBuilder BuildSystemDefaultNamespace;
-NamespaceBuilder BuildMediaNamespace;
-NamespaceBuilder BuildArtNamespace;
-NamespaceBuilder BuildConscryptNamespace;
-NamespaceBuilder BuildResolvNamespace;
-NamespaceBuilder BuildSphalNamespace;
-NamespaceBuilder BuildRsNamespace;
-NamespaceBuilder BuildVndkNamespace;
-NamespaceBuilder BuildVendorDefaultNamespace;
-NamespaceBuilder BuildSystemNamespace;
-NamespaceBuilder BuildVndkInSystemNamespace;
-NamespaceBuilder BuildUnrestrictedDefaultNamespace;
-NamespaceBuilder BuildPostInstallNamespace;
-NamespaceBuilder BuildNeuralNetworksNamespace;
-NamespaceBuilder BuildRuntimeNamespace;
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/include/linkerconfig/sectionbuilder.h b/contents/include/linkerconfig/sectionbuilder.h
deleted file mode 100644
index 0c08358..0000000
--- a/contents/include/linkerconfig/sectionbuilder.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "linkerconfig/context.h"
-#include "linkerconfig/section.h"
-
-typedef android::linkerconfig::modules::Section SectionBuilder(
- android::linkerconfig::contents::Context& ctx);
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-SectionBuilder BuildSystemSection;
-SectionBuilder BuildVendorSection;
-SectionBuilder BuildUnrestrictedSection;
-SectionBuilder BuildLegacySection;
-SectionBuilder BuildPostInstallSection;
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/contents/namespace/art.cc b/contents/namespace/art.cc
deleted file mode 100644
index 559ac0c..0000000
--- a/contents/namespace/art.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-
-Namespace BuildArtNamespace([[maybe_unused]] const Context& ctx) {
- // Make the namespace visible to allow links to be created at runtime, e.g.
- // through android_link_namespaces in libnativeloader. That is not applicable
- // to the vendor section.
- Namespace ns("art",
- /*is_isolated=*/true,
- /*is_visible=*/!ctx.IsVendorSection());
-
- ns.AddSearchPath("/apex/com.android.art/${LIB}", AsanPath::SAME_PATH);
-
- // Need allow_all_shared_libs to let libart.so dlopen oat files in
- // /system/framework and /data.
- // TODO(b/130340935): Use a dynamically created linker namespace similar to
- // classloader-namespace for oat files, and tighten this up.
- ns.GetLink(ctx.GetSystemNamespaceName()).AllowAllSharedLibs();
-
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/conscrypt.cc b/contents/namespace/conscrypt.cc
deleted file mode 100644
index 2bb765d..0000000
--- a/contents/namespace/conscrypt.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-#include <string>
-#include <vector>
-
-#include "linkerconfig/environment.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildConscryptNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("conscrypt", /*is_isolated=*/true,
- /*is_visible=*/true);
-
- ns.AddSearchPath("/apex/com.android.conscrypt/${LIB}", AsanPath::SAME_PATH);
- ns.GetLink("art").AddSharedLib("libandroidio.so");
- ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("liblog.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/media.cc b/contents/namespace/media.cc
deleted file mode 100644
index 0208963..0000000
--- a/contents/namespace/media.cc
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-#include <string>
-#include <vector>
-
-#include "linkerconfig/environment.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Link;
-using android::linkerconfig::modules::Namespace;
-
-namespace {
-const std::vector<std::string> kLibsFromDefaultLegacy = {"libandroid.so",
- "libbinder_ndk.so",
- "libcgrouprc.so",
- "liblog.so",
- "libmediametrics.so",
- "libmediandk.so",
- "libvndksupport.so"};
-
-const std::vector<std::string> kLibsFromDefault = {"@{LLNDK_LIBRARIES}",
- "libbinder_ndk.so",
- "libmediametrics.so"};
-
-const std::vector<std::string> kLibsFromDefaultSystem = {"libcgrouprc.so"};
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildMediaNamespace([[maybe_unused]] const Context& ctx) {
- bool is_legacy = ctx.IsLegacyConfig();
- bool is_vndklite = ctx.IsVndkliteConfig();
- bool is_system_section = ctx.IsSystemSection();
-
- Namespace ns("media", /*is_isolated=*/true, /*is_visible=*/true);
- ns.AddSearchPath("/apex/com.android.media/${LIB}", AsanPath::SAME_PATH);
- ns.AddPermittedPath(
- "/apex/com.android.media/${LIB}/extractors",
- (is_legacy || is_vndklite) ? AsanPath::NONE : AsanPath::SAME_PATH);
-
- Link& system_link = ns.GetLink(ctx.GetSystemNamespaceName());
- if (is_legacy) {
- system_link.AddSharedLib(kLibsFromDefaultLegacy);
- } else {
- system_link.AddSharedLib(kLibsFromDefault);
- if (is_system_section && !is_vndklite) {
- system_link.AddSharedLib(kLibsFromDefaultSystem);
- }
- }
-
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/neuralnetworks.cc b/contents/namespace/neuralnetworks.cc
deleted file mode 100644
index 49add82..0000000
--- a/contents/namespace/neuralnetworks.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "linkerconfig/namespacebuilder.h"
-
-#include "linkerconfig/environment.h"
-#include "linkerconfig/namespace.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildNeuralNetworksNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("neuralnetworks", /*is_isolated=*/true, /*is_visible=*/true);
- ns.AddSearchPath("/apex/com.android.neuralnetworks/${LIB}",
- AsanPath::SAME_PATH);
-
- ns.GetLink(ctx.GetSystemNamespaceName())
- .AddSharedLib({"libcgrouprc.so",
- "liblog.so",
- "libnativewindow.so",
- "libneuralnetworks_packageinfo.so",
- "libsync.so",
- "libvndksupport.so"});
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/postinstall.cc b/contents/namespace/postinstall.cc
deleted file mode 100644
index 3ac3bd4..0000000
--- a/contents/namespace/postinstall.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildPostInstallNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("default", /*is_isolated=*/false,
- /*is_visible=*/false);
- ns.AddSearchPath("/system/${LIB}", AsanPath::NONE);
- ns.AddSearchPath("/@{SYSTEM_EXT:system_ext}/${LIB}", AsanPath::NONE);
- ns.AddSearchPath("/@{PRODUCT:product}/${LIB}", AsanPath::NONE);
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/contents/namespace/resolv.cc b/contents/namespace/resolv.cc
deleted file mode 100644
index 3156fa3..0000000
--- a/contents/namespace/resolv.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-#include <string>
-#include <vector>
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace {
-const std::vector<std::string> kLibsFromDefault = {"libcgrouprc.so",
- "libbinder_ndk.so",
- "liblog.so",
- "libvndksupport.so"};
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildResolvNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("resolv", /*is_isolated=*/true, /*is_visible=*/true);
- ns.AddSearchPath("/apex/com.android.resolv/${LIB}", AsanPath::SAME_PATH);
-
- ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib(kLibsFromDefault);
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/rs.cc b/contents/namespace/rs.cc
deleted file mode 100644
index df6e988..0000000
--- a/contents/namespace/rs.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildRsNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("rs", /*is_isolated=*/true, /*is_visible=*/true);
-
- ns.AddSearchPath("/odm/${LIB}/vndk-sp", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}/vndk-sp", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/apex/com.android.vndk.v@{VNDK_VER}/${LIB}",
- AsanPath::SAME_PATH);
- ns.AddSearchPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
-
- ns.AddPermittedPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/system/vendor/${LIB}", AsanPath::NONE);
- ns.AddPermittedPath("/data", AsanPath::SAME_PATH);
-
- ns.GetLink(ctx.GetSystemNamespaceName())
- .AddSharedLib({"@{LLNDK_LIBRARIES}", "@{PRIVATE_LLNDK_LIBRARIES:}"});
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/runtime.cc b/contents/namespace/runtime.cc
deleted file mode 100644
index 564cb17..0000000
--- a/contents/namespace/runtime.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-
-Namespace BuildRuntimeNamespace([[maybe_unused]] const Context& ctx) {
- // Currently, the runtime namespace is only to isolate
- // libc_malloc_hooks/debug.so. libc/l/d are loaded in the default namespace.
- Namespace ns("runtime",
- /*is_isolated=*/true,
- /*is_visible=*/true);
-
- ns.AddSearchPath("/apex/com.android.runtime/${LIB}", AsanPath::SAME_PATH);
-
- ns.GetLink(ctx.GetSystemNamespaceName())
- .AddSharedLib("libc.so", "libdl.so", "libm.so", "liblog.so");
-
- return ns;
-}
-
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/sphal.cc b/contents/namespace/sphal.cc
deleted file mode 100644
index 7a605f9..0000000
--- a/contents/namespace/sphal.cc
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildSphalNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("sphal", /*is_isolated=*/true, /*is_visible=*/true);
- ns.AddSearchPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}/hw", AsanPath::NONE);
-
- ns.AddPermittedPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/system/vendor/${LIB}", AsanPath::NONE);
-
- ns.GetLink("rs").AddSharedLib("libRS_internal.so");
- ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("@{LLNDK_LIBRARIES:}");
- ns.GetLink("vndk").AddSharedLib("@{VNDK_SAMEPROCESS_LIBRARIES:}");
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/system.cc b/contents/namespace/system.cc
deleted file mode 100644
index 841abbb..0000000
--- a/contents/namespace/system.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildSystemNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("system", /*is_isolated=*/false, /*is_visible=*/false);
- ns.AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{SYSTEM_EXT:system_ext}/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{PRODUCT:product}/${LIB}", AsanPath::WITH_DATA_ASAN);
-
- ns.GetLink("art").AddSharedLib(
- {"libdexfile_external.so",
- "libdexfiled_external.so",
- "libnativebridge.so",
- "libnativehelper.so",
- "libnativeloader.so",
- "libandroidicu.so",
- // TODO(b/120786417 or b/134659294): libicuuc.so
- // and libicui18n.so are kept for app compat.
- "libicui18n.so",
- "libicuuc.so"});
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/systemdefault.cc b/contents/namespace/systemdefault.cc
deleted file mode 100644
index 03bee7c..0000000
--- a/contents/namespace/systemdefault.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/environment.h"
-#include "linkerconfig/namespace.h"
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace {
-const std::vector<std::string> kLibsFromArt = {
- "libdexfile_external.so",
- "libdexfiled_external.so",
- "libnativebridge.so",
- "libnativehelper.so",
- "libnativeloader.so",
- "libandroidicu.so",
- "libpac.so",
- // TODO(b/120786417 or b/134659294): libicuuc.so
- // and libicui18n.so are kept for app compat.
- "libicui18n.so",
- "libicuuc.so",
-};
-
-const std::vector<std::string> kPermittedPaths = {
- "/system/${LIB}/drm",
- "/system/${LIB}/extractors",
- "/system/${LIB}/hw",
- "/@{SYSTEM_EXT:system_ext}/${LIB}",
- "/@{PRODUCT:product}/${LIB}",
- // These are where odex files are located. libart has to be able to
- // dlopen the files
- "/system/framework",
- "/system/app",
- "/system/priv-app",
- "/@{SYSTEM_EXT:system_ext}/framework",
- "/@{SYSTEM_EXT:system_ext}/app",
- "/@{SYSTEM_EXT:system_ext}/priv-app",
- "/vendor/framework",
- "/vendor/app",
- "/vendor/priv-app",
- "/system/vendor/framework",
- "/system/vendor/app",
- "/system/vendor/priv-app",
- "/odm/framework",
- "/odm/app",
- "/odm/priv-app",
- "/oem/app",
- "/@{PRODUCT:product}/framework",
- "/@{PRODUCT:product}/app",
- "/@{PRODUCT:product}/priv-app",
- "/data",
- "/mnt/expand",
- "/apex/com.android.runtime/${LIB}/bionic",
- "/system/${LIB}/bootstrap"};
-
-void BuildPermittedPath(Namespace& ns) {
- for (const auto& path : kPermittedPaths) {
- ns.AddPermittedPath(path, AsanPath::SAME_PATH);
- }
-}
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildSystemDefaultNamespace([[maybe_unused]] const Context& ctx) {
- bool is_fully_treblelized = ctx.IsDefaultConfig();
- Namespace ns("default",
- /*is_isolated=*/is_fully_treblelized,
- /*is_visible=*/true);
-
- ns.AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{SYSTEM_EXT:system_ext}/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{PRODUCT:product}/${LIB}", AsanPath::WITH_DATA_ASAN);
- if (!is_fully_treblelized) {
- ns.AddSearchPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
- }
-
- if (is_fully_treblelized) {
- BuildPermittedPath(ns);
- }
-
- ns.GetLink("art").AddSharedLib(kLibsFromArt);
-
- ns.GetLink("resolv").AddSharedLib("libnetd_resolv.so");
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/unrestricteddefault.cc b/contents/namespace/unrestricteddefault.cc
deleted file mode 100644
index 11408a4..0000000
--- a/contents/namespace/unrestricteddefault.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-#include "linkerconfig/environment.h"
-#include "linkerconfig/namespace.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace {
-const std::vector<std::string> kLibsFromArt = {
- "libdexfile_external.so",
- "libdexfiled_external.so",
- "libnativebridge.so",
- "libnativehelper.so",
- "libnativeloader.so",
- "libandroidicu.so",
- "libpac.so",
- // TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept
- // for app compat.
- "libicui18n.so",
- "libicuuc.so"};
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildUnrestrictedDefaultNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("default", /*is_isolated=*/false, /*is_visible=*/true);
-
- ns.AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
-
- ns.GetLink("art").AddSharedLib(kLibsFromArt);
- ns.GetLink("resolv").AddSharedLib("libnetd_resolv.so");
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/vendordefault.cc b/contents/namespace/vendordefault.cc
deleted file mode 100644
index efbfc03..0000000
--- a/contents/namespace/vendordefault.cc
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/environment.h"
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::GetVendorVndkVersion;
-using android::linkerconfig::modules::Namespace;
-
-namespace {
-const std::vector<std::string> kVndkLiteArtLibs = {
- "libdexfile_external.so",
- "libdexfiled_external.so",
- "libnativebridge.so",
- "libnativehelper.so",
- "libnativeloader.so",
- // TODO(b/120786417 or b/134659294): libicuuc.so
- // and libicui18n.so are kept for app compat.
- "libicui18n.so",
- "libicuuc.so",
-};
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildVendorDefaultNamespace([[maybe_unused]] const Context& ctx) {
- bool is_vndklite = ctx.IsVndkliteConfig();
-
- Namespace ns(
- "default", /*is_isolated=*/!is_vndklite, /*is_visible=*/!is_vndklite);
-
- ns.AddSearchPath("/odm/${LIB}", AsanPath::WITH_DATA_ASAN);
- // Allow loosen restriction between vndk and private platform libraries
- if (is_vndklite) {
- ns.AddSearchPath("/odm/${LIB}/vndk", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/odm/${LIB}/vndk-sp", AsanPath::WITH_DATA_ASAN);
- }
-
- ns.AddSearchPath("/vendor/${LIB}", AsanPath::WITH_DATA_ASAN);
- // Allow loosen restriction between vndk and private platform libraries
- if (is_vndklite) {
- ns.AddSearchPath("/vendor/${LIB}/vndk", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}/vndk-sp", AsanPath::WITH_DATA_ASAN);
- }
-
- // VNDK-Lite devices require broader access from vendor to system/product partition
- if (is_vndklite) {
- ns.AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{SYSTEM_EXT:system_ext}/${LIB}",
- AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{PRODUCT:product}/${LIB}", AsanPath::WITH_DATA_ASAN);
- // Put system vndk at the last search order in vndk_lite for GSI
- ns.AddSearchPath("/apex/com.android.vndk.v@{VNDK_VER}/${LIB}",
- AsanPath::SAME_PATH);
- }
-
- if (ctx.IsDefaultConfig() && GetVendorVndkVersion() == "27") {
- ns.AddSearchPath("/vendor/${LIB}/hw", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}/egl", AsanPath::WITH_DATA_ASAN);
- }
-
- ns.AddPermittedPath("/odm", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/vendor", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/system/vendor", AsanPath::NONE);
-
- if (is_vndklite) {
- ns.GetLink("art").AddSharedLib(kVndkLiteArtLibs);
- } else {
- ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("@{LLNDK_LIBRARIES}");
- ns.GetLink("vndk").AddSharedLib(
- {"@{VNDK_SAMEPROCESS_LIBRARIES}", "@{VNDK_CORE_LIBRARIES}"});
- if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
- ns.GetLink("vndk_in_system")
- .AddSharedLib("@{VNDK_USING_CORE_VARIANT_LIBRARIES}");
- }
- }
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/vndk.cc b/contents/namespace/vndk.cc
deleted file mode 100644
index 2ffeef7..0000000
--- a/contents/namespace/vndk.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-#include "linkerconfig/environment.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildVndkNamespace([[maybe_unused]] const Context& ctx) {
- bool is_system_section = ctx.IsSystemSection();
- bool is_vndklite = ctx.IsVndkliteConfig();
- Namespace ns("vndk",
- /*is_isolated=*/is_system_section,
- /*is_visible=*/is_system_section);
-
- ns.AddSearchPath("/odm/${LIB}/vndk-sp", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}/vndk-sp", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/apex/com.android.vndk.v@{VNDK_VER}/${LIB}",
- AsanPath::SAME_PATH);
-
- if (!is_system_section) {
- ns.AddSearchPath("/odm/${LIB}/vndk", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/vendor/${LIB}/vndk", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/apex/com.android.vndk.v@{VNDK_VER}/${LIB}",
- AsanPath::SAME_PATH);
- }
-
- if (is_system_section) {
- ns.AddPermittedPath("/odm/${LIB}/hw", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/odm/${LIB}/egl", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/vendor/${LIB}/hw", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/vendor/${LIB}/egl", AsanPath::WITH_DATA_ASAN);
- if (!is_vndklite) {
- ns.AddPermittedPath("/system/vendor/${LIB}/hw", AsanPath::NONE);
- }
- ns.AddPermittedPath("/system/vendor/${LIB}/egl", AsanPath::NONE);
- ns.AddPermittedPath("/apex/com.android.vndk.v@{VNDK_VER}/${LIB}/hw",
- AsanPath::SAME_PATH);
- }
-
- ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib({"@{LLNDK_LIBRARIES}"});
-
- if (!is_vndklite) {
- if (is_system_section) {
- ns.GetLink("sphal").AllowAllSharedLibs();
- } else {
- ns.GetLink("default").AllowAllSharedLibs();
-
- if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
- ns.GetLink("vndk_in_system")
- .AddSharedLib("@{VNDK_USING_CORE_VARIANT_LIBRARIES}");
- }
- }
- }
-
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/namespace/vndkinsystem.cc b/contents/namespace/vndkinsystem.cc
deleted file mode 100644
index 87beb8b..0000000
--- a/contents/namespace/vndkinsystem.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/namespacebuilder.h"
-
-#include "linkerconfig/environment.h"
-
-using android::linkerconfig::modules::AsanPath;
-using android::linkerconfig::modules::Namespace;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Namespace BuildVndkInSystemNamespace([[maybe_unused]] const Context& ctx) {
- Namespace ns("vndk_in_system", /*is_isolated=*/true,
- /*is_visible=*/true);
-
- ns.AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{SYSTEM_EXT:system_ext}/${LIB}", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/@{PRODUCT:product}/${LIB}", AsanPath::WITH_DATA_ASAN);
-
- if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
- ns.AddWhitelisted("@{VNDK_USING_CORE_VARIANT_LIBRARIES}");
- }
-
- ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("@{LLNDK_LIBRARIES}");
- ns.GetLink("vndk").AllowAllSharedLibs();
- ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
-
- return ns;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/section/legacy.cc b/contents/section/legacy.cc
deleted file mode 100644
index c3d0940..0000000
--- a/contents/section/legacy.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/sectionbuilder.h"
-
-#include "linkerconfig/common.h"
-#include "linkerconfig/namespacebuilder.h"
-#include "linkerconfig/section.h"
-
-using android::linkerconfig::contents::SectionType;
-using android::linkerconfig::modules::Namespace;
-using android::linkerconfig::modules::Section;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Section BuildLegacySection(Context& ctx) {
- ctx.SetCurrentSection(SectionType::System);
- std::vector<Namespace> namespaces;
-
- namespaces.emplace_back(BuildSystemDefaultNamespace(ctx));
- namespaces.emplace_back(BuildArtNamespace(ctx));
- namespaces.emplace_back(BuildMediaNamespace(ctx));
- namespaces.emplace_back(BuildConscryptNamespace(ctx));
- namespaces.emplace_back(BuildResolvNamespace(ctx));
- namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx));
- namespaces.emplace_back(BuildRuntimeNamespace(ctx));
-
- Section section("legacy", std::move(namespaces));
- AddStandardSystemLinks(ctx, §ion);
- return section;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/section/postinstall.cc b/contents/section/postinstall.cc
deleted file mode 100644
index 0f54c45..0000000
--- a/contents/section/postinstall.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/sectionbuilder.h"
-
-#include "linkerconfig/namespacebuilder.h"
-
-using android::linkerconfig::contents::SectionType;
-using android::linkerconfig::modules::Namespace;
-using android::linkerconfig::modules::Section;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Section BuildPostInstallSection(Context& ctx) {
- ctx.SetCurrentSection(SectionType::Other);
- std::vector<Namespace> namespaces;
-
- namespaces.emplace_back(BuildPostInstallNamespace(ctx));
-
- return Section("postinstall", std::move(namespaces));
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/contents/section/system.cc b/contents/section/system.cc
deleted file mode 100644
index d944f5f..0000000
--- a/contents/section/system.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/sectionbuilder.h"
-
-#include "linkerconfig/common.h"
-#include "linkerconfig/context.h"
-#include "linkerconfig/namespacebuilder.h"
-#include "linkerconfig/section.h"
-
-using android::linkerconfig::contents::SectionType;
-using android::linkerconfig::modules::Namespace;
-using android::linkerconfig::modules::Section;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Section BuildSystemSection(Context& ctx) {
- ctx.SetCurrentSection(SectionType::System);
- std::vector<Namespace> namespaces;
-
- namespaces.emplace_back(BuildSystemDefaultNamespace(ctx));
- namespaces.emplace_back(BuildArtNamespace(ctx));
- namespaces.emplace_back(BuildMediaNamespace(ctx));
- namespaces.emplace_back(BuildConscryptNamespace(ctx));
- namespaces.emplace_back(BuildResolvNamespace(ctx));
- namespaces.emplace_back(BuildSphalNamespace(ctx));
- namespaces.emplace_back(BuildRsNamespace(ctx));
- namespaces.emplace_back(BuildVndkNamespace(ctx));
- namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx));
- namespaces.emplace_back(BuildRuntimeNamespace(ctx));
-
- Section section("system", std::move(namespaces));
- AddStandardSystemLinks(ctx, §ion);
- return section;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/section/unrestricted.cc b/contents/section/unrestricted.cc
deleted file mode 100644
index ae57426..0000000
--- a/contents/section/unrestricted.cc
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/sectionbuilder.h"
-
-#include "linkerconfig/common.h"
-#include "linkerconfig/environment.h"
-#include "linkerconfig/namespacebuilder.h"
-#include "linkerconfig/section.h"
-
-using android::linkerconfig::contents::SectionType;
-using android::linkerconfig::modules::Namespace;
-using android::linkerconfig::modules::Section;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Section BuildUnrestrictedSection(Context& ctx) {
- ctx.SetCurrentSection(SectionType::Other);
- std::vector<Namespace> namespaces;
-
- namespaces.emplace_back(BuildUnrestrictedDefaultNamespace(ctx));
- namespaces.emplace_back(BuildArtNamespace(ctx));
- namespaces.emplace_back(BuildMediaNamespace(ctx));
- namespaces.emplace_back(BuildConscryptNamespace(ctx));
- namespaces.emplace_back(BuildResolvNamespace(ctx));
- namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx));
-
- Section section("unrestricted", std::move(namespaces));
- AddStandardSystemLinks(ctx, §ion);
- return section;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/section/vendor.cc b/contents/section/vendor.cc
deleted file mode 100644
index f872be3..0000000
--- a/contents/section/vendor.cc
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/sectionbuilder.h"
-
-#include "linkerconfig/common.h"
-#include "linkerconfig/environment.h"
-#include "linkerconfig/namespacebuilder.h"
-#include "linkerconfig/section.h"
-
-using android::linkerconfig::contents::SectionType;
-using android::linkerconfig::modules::Namespace;
-using android::linkerconfig::modules::Section;
-
-namespace android {
-namespace linkerconfig {
-namespace contents {
-Section BuildVendorSection(Context& ctx) {
- ctx.SetCurrentSection(SectionType::Vendor);
- std::vector<Namespace> namespaces;
-
- bool is_vndklite = ctx.IsVndkliteConfig();
-
- namespaces.emplace_back(BuildVendorDefaultNamespace(ctx));
- namespaces.emplace_back(BuildArtNamespace(ctx));
- // VNDK-Lite devices does not contain VNDK and System namespace in vendor
- // section. Instead they (except libraries from APEX) will be loaded from
- // default namespace, so VNDK libraries can access private platform libraries.
- if (!is_vndklite) {
- namespaces.emplace_back(BuildVndkNamespace(ctx));
- namespaces.emplace_back(BuildSystemNamespace(ctx));
- }
- namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx));
-
- if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
- namespaces.emplace_back(BuildVndkInSystemNamespace(ctx));
- }
-
- namespaces.emplace_back(BuildRuntimeNamespace(ctx));
-
- Section section("vendor", std::move(namespaces));
- AddStandardSystemLinks(ctx, §ion);
- return section;
-}
-} // namespace contents
-} // namespace linkerconfig
-} // namespace android
diff --git a/contents/tests/backward_compatibility/default_test.cc b/contents/tests/backward_compatibility/default_test.cc
deleted file mode 100644
index 5aae412..0000000
--- a/contents/tests/backward_compatibility/default_test.cc
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include "linkerconfig/baseconfig.h"
-#include "linkerconfig/variables.h"
-#include "testbase.h"
-
-using android::linkerconfig::modules::AsanPath;
-
-TEST(linkerconfig_default_backward_compatibility, common_system_section) {
- MockVariables();
-
- auto config = android::linkerconfig::contents::CreateBaseConfiguration();
-
- auto system_section = config.GetSection("system");
- ASSERT_TRUE(system_section);
-
- auto default_namespace = system_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/vendor/framework",
- AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/vendor/app",
- AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/vendor/priv-app",
- AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath(
- "/system/vendor/framework", AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/system/vendor/app",
- AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath(
- "/system/vendor/priv-app", AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/odm/framework",
- AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/odm/app",
- AsanPath::SAME_PATH));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/odm/priv-app",
- AsanPath::SAME_PATH));
-
- auto sphal_namespace = system_section->GetNamespace("sphal");
- ASSERT_TRUE(sphal_namespace);
-
- ASSERT_TRUE(sphal_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(sphal_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(
- sphal_namespace->ContainsSearchPath("/vendor/${LIB}/hw", AsanPath::NONE));
-
- ASSERT_TRUE(sphal_namespace->ContainsPermittedPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(sphal_namespace->ContainsPermittedPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(sphal_namespace->ContainsPermittedPath("/system/vendor/${LIB}",
- AsanPath::NONE));
-
- auto rs_namespace = system_section->GetNamespace("rs");
- ASSERT_TRUE(rs_namespace);
-
- ASSERT_TRUE(rs_namespace->ContainsSearchPath("/odm/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(rs_namespace->ContainsSearchPath("/vendor/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(rs_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(rs_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
-
- ASSERT_TRUE(rs_namespace->ContainsPermittedPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(rs_namespace->ContainsPermittedPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(rs_namespace->ContainsPermittedPath("/system/vendor/${LIB}",
- AsanPath::NONE));
-
- auto vndk_namespace = system_section->GetNamespace("vndk");
- ASSERT_TRUE(vndk_namespace);
-
- ASSERT_TRUE(vndk_namespace->ContainsSearchPath("/odm/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(vndk_namespace->ContainsSearchPath("/vendor/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
-
- ASSERT_TRUE(vndk_namespace->ContainsPermittedPath("/odm/${LIB}/hw",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(vndk_namespace->ContainsPermittedPath("/odm/${LIB}/egl",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(vndk_namespace->ContainsPermittedPath("/vendor/${LIB}/hw",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(vndk_namespace->ContainsPermittedPath("/vendor/${LIB}/egl",
- AsanPath::WITH_DATA_ASAN));
-}
-
-TEST(linkerconfig_default_backward_compatibility, common_vendor_section) {
- MockVariables();
-
- auto config = android::linkerconfig::contents::CreateBaseConfiguration();
-
- auto vendor_section = config.GetSection("vendor");
- ASSERT_TRUE(vendor_section);
-
- auto default_namespace = vendor_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath(
- "/odm", AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath(
- "/vendor", AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(default_namespace->ContainsPermittedPath("/system/vendor",
- AsanPath::NONE));
-
- auto vndk_namespace = vendor_section->GetNamespace("vndk");
- ASSERT_TRUE(vndk_namespace);
-
- ASSERT_TRUE(vndk_namespace->ContainsSearchPath("/odm/${LIB}/vndk",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(vndk_namespace->ContainsSearchPath("/odm/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(vndk_namespace->ContainsSearchPath("/vendor/${LIB}/vndk",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(vndk_namespace->ContainsSearchPath("/vendor/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
-}
-
-TEST(linkerconfig_default_backward_compatibility, common_unrestricted_section) {
- MockVariables();
-
- auto config = android::linkerconfig::contents::CreateBaseConfiguration();
-
- auto unrestricted_section = config.GetSection("unrestricted");
- ASSERT_TRUE(unrestricted_section);
-
- auto default_namespace = unrestricted_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
-}
-
-TEST(linkerconfig_default_backward_compatibility, vndk_27) {
- MockVariables();
- android::linkerconfig::modules::Variables::AddValue("ro.vndk.version", "27");
-
- auto config = android::linkerconfig::contents::CreateBaseConfiguration();
-
- auto vendor_section = config.GetSection("vendor");
- ASSERT_TRUE(vendor_section);
-
- auto default_namespace = vendor_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}/hw",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}/egl",
- AsanPath::WITH_DATA_ASAN));
-}
diff --git a/contents/tests/backward_compatibility/legacy_test.cc b/contents/tests/backward_compatibility/legacy_test.cc
deleted file mode 100644
index 3afaf79..0000000
--- a/contents/tests/backward_compatibility/legacy_test.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include "linkerconfig/legacy.h"
-#include "linkerconfig/variables.h"
-#include "testbase.h"
-
-using android::linkerconfig::modules::AsanPath;
-
-TEST(linkerconfig_legacy_backward_compatibility, default_namespace) {
- MockVariables();
-
- auto config = android::linkerconfig::contents::CreateLegacyConfiguration();
-
- auto legacy_section = config.GetSection("legacy");
- ASSERT_TRUE(legacy_section);
-
- auto default_namespace = legacy_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- ASSERT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
-}
\ No newline at end of file
diff --git a/contents/tests/backward_compatibility/testbase.h b/contents/tests/backward_compatibility/testbase.h
deleted file mode 100644
index ccfed2e..0000000
--- a/contents/tests/backward_compatibility/testbase.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "linkerconfig/variables.h"
-
-inline void MockVariables(std::string vndk_ver = "Q") {
- android::linkerconfig::modules::Variables::AddValue("VNDK_VER", vndk_ver);
- android::linkerconfig::modules::Variables::AddValue("PRODUCT", "product");
- android::linkerconfig::modules::Variables::AddValue("SYSTEM_EXT",
- "system_ext");
- android::linkerconfig::modules::Variables::AddValue("LLNDK_LIBRARIES",
- "llndk_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "SANITIZER_RUNTIME_LIBRARIES", "sanitizer_runtime_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "PRIVATE_LLNDK_LIBRARIES", "private_llndk_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "VNDK_SAMEPROCESS_LIBRARIES", "vndk_sameprocess_libraries");
- android::linkerconfig::modules::Variables::AddValue("VNDK_CORE_LIBRARIES",
- "vndk_core_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "VNDK_USING_CORE_VARIANT_LIBRARIES", "vndk_using_core_variant_libraries");
-}
-
-inline void MockVnkdLite() {
- android::linkerconfig::modules::Variables::AddValue("ro.vndk.lite", "true");
-}
\ No newline at end of file
diff --git a/contents/tests/backward_compatibility/vndklite_test.cc b/contents/tests/backward_compatibility/vndklite_test.cc
deleted file mode 100644
index 73b5aa7..0000000
--- a/contents/tests/backward_compatibility/vndklite_test.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <gtest/gtest.h>
-
-#include "linkerconfig/baseconfig.h"
-#include "linkerconfig/variables.h"
-#include "testbase.h"
-
-using android::linkerconfig::modules::AsanPath;
-
-TEST(linkerconfig_vndklite_backward_compatibility, system_section) {
- MockVariables();
- MockVnkdLite();
-
- auto config = android::linkerconfig::contents::CreateBaseConfiguration();
-
- auto system_section = config.GetSection("system");
- ASSERT_TRUE(system_section);
-
- auto default_namespace = system_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
-
- auto sphal_namespace = system_section->GetNamespace("sphal");
- ASSERT_TRUE(sphal_namespace);
-
- EXPECT_TRUE(sphal_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(sphal_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(
- sphal_namespace->ContainsSearchPath("/vendor/${LIB}/hw", AsanPath::NONE));
-
- EXPECT_TRUE(sphal_namespace->ContainsPermittedPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(sphal_namespace->ContainsPermittedPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(sphal_namespace->ContainsPermittedPath("/system/vendor/${LIB}",
- AsanPath::NONE));
-
- auto rs_namespace = system_section->GetNamespace("rs");
- ASSERT_TRUE(rs_namespace);
-
- EXPECT_TRUE(rs_namespace->ContainsSearchPath("/odm/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(rs_namespace->ContainsSearchPath("/vendor/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(rs_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(rs_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
-
- EXPECT_TRUE(rs_namespace->ContainsPermittedPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(rs_namespace->ContainsPermittedPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(rs_namespace->ContainsPermittedPath("/system/vendor/${LIB}",
- AsanPath::NONE));
-
- auto vndk_namespace = system_section->GetNamespace("vndk");
- ASSERT_TRUE(vndk_namespace);
-
- EXPECT_TRUE(vndk_namespace->ContainsSearchPath("/odm/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(vndk_namespace->ContainsSearchPath("/vendor/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
-
- EXPECT_TRUE(vndk_namespace->ContainsPermittedPath("/odm/${LIB}/hw",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(vndk_namespace->ContainsPermittedPath("/odm/${LIB}/egl",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(vndk_namespace->ContainsPermittedPath("/vendor/${LIB}/hw",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(vndk_namespace->ContainsPermittedPath("/vendor/${LIB}/egl",
- AsanPath::WITH_DATA_ASAN));
-}
-
-TEST(linkerconfig_vndklite_backward_compatibility, vendor_section) {
- MockVariables();
- MockVnkdLite();
-
- auto config = android::linkerconfig::contents::CreateBaseConfiguration();
-
- auto vendor_section = config.GetSection("vendor");
- ASSERT_TRUE(vendor_section);
-
- auto default_namespace = vendor_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}/vndk",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}/vndk",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}/vndk-sp",
- AsanPath::WITH_DATA_ASAN));
-}
-
-TEST(linkerconfig_vndklite_backward_compatibility, unrestricted_section) {
- MockVariables();
- MockVnkdLite();
-
- auto config = android::linkerconfig::contents::CreateBaseConfiguration();
-
- auto unrestricted_section = config.GetSection("unrestricted");
- ASSERT_TRUE(unrestricted_section);
-
- auto default_namespace = unrestricted_section->GetNamespace("default");
- ASSERT_TRUE(default_namespace);
-
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/odm/${LIB}",
- AsanPath::WITH_DATA_ASAN));
- EXPECT_TRUE(default_namespace->ContainsSearchPath("/vendor/${LIB}",
- AsanPath::WITH_DATA_ASAN));
-}
\ No newline at end of file
diff --git a/contents/tests/configuration/baseconfig_test.cc b/contents/tests/configuration/baseconfig_test.cc
deleted file mode 100644
index c10003d..0000000
--- a/contents/tests/configuration/baseconfig_test.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/baseconfig.h"
-#include "configurationtest.h"
-#include "linkerconfig/configwriter.h"
-#include "mockenv.h"
-
-TEST(linkerconfig_configuration_fulltest, baseconfig_test) {
- MockGenericVariables();
- auto base_config = android::linkerconfig::contents::CreateBaseConfiguration();
- android::linkerconfig::modules::ConfigWriter config_writer;
-
- base_config.WriteConfig(config_writer);
-
- VerifyConfiguration(config_writer.ToString());
-}
-
-TEST(linkerconfig_configuration_fulltest,
- baseconfig_vndk_using_core_variant_test) {
- MockGenericVariables();
- MockVndkUsingCoreVariant();
-
- auto base_config = android::linkerconfig::contents::CreateBaseConfiguration();
- android::linkerconfig::modules::ConfigWriter config_writer;
-
- base_config.WriteConfig(config_writer);
-
- VerifyConfiguration(config_writer.ToString());
-}
-
-TEST(linkerconfig_configuration_fulltest, baseconfig_vndk_27_test) {
- MockGenericVariables();
- MockVndkVersion("27");
- auto base_config = android::linkerconfig::contents::CreateBaseConfiguration();
- android::linkerconfig::modules::ConfigWriter config_writer;
-
- base_config.WriteConfig(config_writer);
-
- VerifyConfiguration(config_writer.ToString());
-}
-
-TEST(linkerconfig_configuration_fulltest, vndklite_test) {
- MockGenericVariables();
- MockVnkdLite();
-
- auto vndklite_config =
- android::linkerconfig::contents::CreateBaseConfiguration();
- android::linkerconfig::modules::ConfigWriter config_writer;
-
- vndklite_config.WriteConfig(config_writer);
-
- VerifyConfiguration(config_writer.ToString());
-}
\ No newline at end of file
diff --git a/contents/tests/configuration/include/configurationtest.h b/contents/tests/configuration/include/configurationtest.h
deleted file mode 100644
index 0846037..0000000
--- a/contents/tests/configuration/include/configurationtest.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <unordered_set>
-
-#include "gtest/gtest.h"
-#include "linkerconfigparser.h"
-#include "modules.h"
-
-namespace {
-inline void TraverseLink(const Namespace& ns, std::unordered_set<std::string>& visible_ns) {
- if (visible_ns.count(ns.name) != 0) {
- return;
- }
-
- visible_ns.insert(ns.name);
-
- for (auto& [_, link] : ns.links) {
- TraverseLink(*link.to, visible_ns);
- }
-}
-
-inline void ValidateAllNamespacesAreVisible(const Section& section) {
- std::unordered_set<std::string> visible_ns;
- for (auto& [_, ns] : section.namespaces) {
- if (ns.name == "default" || ns.is_visible) {
- TraverseLink(ns, visible_ns);
- }
- }
-
- for (auto& [_, ns] : section.namespaces) {
- EXPECT_EQ(1u, visible_ns.count(ns.name))
- << "Namespace " << ns.name << " is not visible from section " << section.name;
- }
-}
-
-inline void ValidateNamespace(const Namespace& target_namespace, const Section& parent_section) {
- EXPECT_FALSE(target_namespace.name.empty()) << "Namespace name should not be empty";
- EXPECT_FALSE(target_namespace.search_path.empty() && target_namespace.permitted_path.empty())
- << "Search path or permitted path should be defined in namespace " << target_namespace.name
- << " from section " << parent_section.name;
-}
-
-inline void ValidateSection(const Section& section) {
- EXPECT_FALSE(section.name.empty()) << "Section name should not be empty";
- EXPECT_NE(0u, section.namespaces.size())
- << "Section " << section.name << " should contain at least one namespace";
- EXPECT_NE(0u, section.dirs.size())
- << "Section " << section.name << "does not contain any directory as executable path";
- EXPECT_TRUE(MapContainsKey(section.namespaces, std::string("default")))
- << "Section " << section.name << " should contain namespace named 'default'";
-
- for (auto& [_, target_namespace] : section.namespaces) {
- ValidateNamespace(target_namespace, section);
- }
-
- ValidateAllNamespacesAreVisible(section);
-}
-
-inline void ValidateConfiguration(const Configuration& conf) {
- EXPECT_NE(0u, conf.sections.size());
- for (auto& [_, section] : conf.sections) {
- ValidateSection(section);
- }
-}
-} // namespace
-
-inline void VerifyConfiguration(const std::string& configuration_str) {
- Configuration conf;
- ParseConfiguration(configuration_str, conf);
- ValidateConfiguration(conf);
-}
\ No newline at end of file
diff --git a/contents/tests/configuration/include/linkerconfigparser.h b/contents/tests/configuration/include/linkerconfigparser.h
deleted file mode 100644
index 4cd803e..0000000
--- a/contents/tests/configuration/include/linkerconfigparser.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <cstring>
-#include <regex>
-
-#include "gtest/gtest.h"
-#include "modules.h"
-
-namespace {
-constexpr const char* kSectionNameRegex = "\\[\\s*(\\w+)\\s*\\]";
-constexpr const char* kDirRegex = "dir\\.(\\w+)\\s*=\\s*([\\w/]+)";
-constexpr const char* kNamespaceBaseRegex =
- "namespace\\.(\\w+)\\.([^\\s=]+)\\s*(=|\\+=)\\s*([^\\s]+)";
-constexpr const char* kAdditionalNamespacesRegex =
- "additional\\.namespaces\\s*=\\s*((?:[\\w]+)(?:,[\\w]+)*)";
-
-// Functions to parse configuration string and verify syntax
-
-inline void ParseDirPath(const std::string& line, Configuration& conf) {
- static std::regex dir_regex(kDirRegex);
- std::smatch match;
-
- ASSERT_TRUE(std::regex_match(line, match, dir_regex));
- ASSERT_EQ(3u, match.size());
- std::string section_name = match[1];
- std::string dir_path = match[2];
-
- if (!MapContainsKey(conf.sections, section_name)) {
- conf.sections[section_name].name = section_name;
- conf.sections[section_name].namespaces["default"].name = "default";
- }
-
- conf.sections[section_name].dirs.push_back(dir_path);
-}
-
-inline void ParseAdditionalNamespaces(const std::smatch& match,
- Section& current_section) {
- // additional.namespace = a,b,c,e,d
- ASSERT_EQ(2u, match.size());
- std::stringstream namespaces(match[1]);
- for (std::string namespace_name;
- std::getline(namespaces, namespace_name, ',');) {
- EXPECT_FALSE(MapContainsKey(current_section.namespaces, namespace_name));
- Namespace new_namespace;
- new_namespace.name = namespace_name;
- current_section.namespaces[namespace_name] = new_namespace;
- }
-}
-
-inline void ParseNamespacePath(const std::vector<std::string>& property_descs,
- const bool is_additional, const std::string& path,
- Namespace& current_namespace,
- const std::string& line) {
- // namespace.test.(asan.)search|permitted.path =|+= /path/to/${LIB}/dir
- ASSERT_EQ(property_descs[0] == "asan" ? 3u : 2u, property_descs.size());
-
- std::vector<std::string>* target_path = nullptr;
- if (property_descs[0] == "search") {
- target_path = ¤t_namespace.search_path;
- } else if (property_descs[0] == "permitted") {
- target_path = ¤t_namespace.permitted_path;
- } else if (property_descs[0] == "asan" && property_descs[1] == "search") {
- target_path = ¤t_namespace.asan_search_path;
- } else if (property_descs[0] == "asan" && property_descs[1] == "permitted") {
- target_path = ¤t_namespace.asan_permitted_path;
- }
-
- ASSERT_NE(nullptr, target_path);
- EXPECT_EQ(is_additional, target_path->size() != 0)
- << "Path should be marked as = if and only if it is mentioned first : "
- << line;
-
- target_path->push_back(path);
-}
-
-inline void ParseLinkList(const std::vector<std::string>& property_descs,
- const std::string& target_namespaces,
- Namespace& current_namespace,
- Section& current_section, const std::string& line) {
- // namespace.test.links = a,b,c,d,e
- EXPECT_EQ(1u, property_descs.size());
- std::stringstream namespaces(target_namespaces);
- for (std::string namespace_to; std::getline(namespaces, namespace_to, ',');) {
- EXPECT_FALSE(MapContainsKey(current_namespace.links, namespace_to))
- << "Link to " << namespace_to << " is already defined : " << line;
- EXPECT_TRUE(MapContainsKey(current_section.namespaces, namespace_to))
- << "Target namespace is not defined in section : " << line;
-
- current_namespace.links[namespace_to].from = ¤t_namespace;
- current_namespace.links[namespace_to].to =
- ¤t_section.namespaces[namespace_to];
- current_namespace.links[namespace_to].allow_all_shared = false;
- }
-}
-
-inline void ParseLink(const std::vector<std::string>& property_descs,
- const bool is_additional, const std::string& value,
- Namespace& current_namespace, Section& current_section,
- const std::string& line) {
- // namespace.from.link.to.shared_libs = a.so
- // namespace.from.link.to.allow_all_shared_libs = true
- ASSERT_EQ(3u, property_descs.size());
- ASSERT_TRUE(property_descs[2] == "shared_libs" ||
- property_descs[2] == "allow_all_shared_libs");
- std::string namespace_to = property_descs[1];
-
- ASSERT_TRUE(MapContainsKey(current_section.namespaces, namespace_to))
- << "To namespace does not exist in section " << current_section.name
- << " : " << line;
-
- if (property_descs[2] == "shared_libs") {
- EXPECT_EQ(is_additional,
- current_namespace.links[namespace_to].shared_libs.size() != 0)
- << "Link should be defined with = if and only if it is first link "
- "between two namespaces : "
- << line;
-
- current_namespace.links[namespace_to].shared_libs.push_back(value);
- } else {
- EXPECT_EQ("true", value);
- current_namespace.links[namespace_to].allow_all_shared = true;
- }
-}
-
-inline void ParseNamespaceCommand(const std::string& namespace_name,
- const std::string& property_desc,
- const bool is_additional_property,
- const std::string& value,
- Section& current_section,
- const std::string& line) {
- ASSERT_TRUE(MapContainsKey(current_section.namespaces, namespace_name))
- << "Namespace " << namespace_name << " does not exist in section "
- << current_section.name << " : " << line;
- Namespace& current_namespace = current_section.namespaces[namespace_name];
-
- std::vector<std::string> property_descs;
- std::stringstream property_desc_stream(property_desc);
- for (std::string property;
- std::getline(property_desc_stream, property, '.');) {
- property_descs.push_back(property);
- }
-
- ASSERT_TRUE(property_descs.size() > 0)
- << "There should be at least one property description after namespace."
- << namespace_name << " : " << line;
-
- if (property_descs[0].compare("isolated") == 0) {
- // namespace.test.isolated = true
- EXPECT_EQ(1u, property_descs.size());
- EXPECT_TRUE(value == "true" || value == "false");
- current_namespace.is_isolated = value == "true";
- } else if (property_descs[0].compare("visible") == 0) {
- // namespace.test.visible = true
- EXPECT_EQ(1u, property_descs.size());
- EXPECT_TRUE(value == "true" || value == "false");
- current_namespace.is_visible = value == "true";
- } else if (property_descs[property_descs.size() - 1] == "paths") {
- // namespace.test.search.path += /system/lib
- ParseNamespacePath(
- property_descs, is_additional_property, value, current_namespace, line);
- } else if (property_descs[0] == "links") {
- // namespace.test.links = a,b,c
- ParseLinkList(
- property_descs, value, current_namespace, current_section, line);
- } else if (property_descs[0] == "link") {
- // namespace.test.link.a = libc.so
- ParseLink(property_descs,
- is_additional_property,
- value,
- current_namespace,
- current_section,
- line);
- } else if (property_descs[0] == "whitelisted") {
- EXPECT_EQ(1u, property_descs.size());
- current_namespace.whitelisted.push_back(value);
- } else {
- EXPECT_TRUE(false) << "Failed to parse line : " << line;
- }
-}
-} // namespace
-
-inline void ParseConfiguration(const std::string& configuration_str,
- Configuration& conf) {
- Section* current_section = nullptr;
-
- static std::regex section_name_regex(kSectionNameRegex);
- static std::regex additional_namespaces_regex(kAdditionalNamespacesRegex);
- static std::regex namespace_base_regex(kNamespaceBaseRegex);
-
- std::smatch match;
-
- std::stringstream configuration_stream(configuration_str);
-
- for (std::string line; std::getline(configuration_stream, line);) {
- // Skip empty line
- if (line.empty()) {
- continue;
- }
-
- if (std::regex_match(line, match, section_name_regex)) {
- // [section_name]
- ASSERT_EQ(2u, match.size());
- std::string section_name = match[1];
- ASSERT_TRUE(MapContainsKey(conf.sections, section_name));
- current_section = &conf.sections[section_name];
-
- continue;
- }
-
- if (current_section == nullptr) {
- ParseDirPath(line, conf);
- } else {
- if (std::regex_match(line, match, additional_namespaces_regex)) {
- ParseAdditionalNamespaces(match, *current_section);
- } else {
- EXPECT_TRUE(std::regex_match(line, match, namespace_base_regex));
- ASSERT_EQ(5u, match.size());
- std::string namespace_name = match[1];
- std::string property_desc = match[2];
- bool is_additional_property = match[3] == "+=";
- std::string content = match[4];
- ParseNamespaceCommand(namespace_name,
- property_desc,
- is_additional_property,
- content,
- *current_section,
- line);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/contents/tests/configuration/include/mockenv.h b/contents/tests/configuration/include/mockenv.h
deleted file mode 100644
index 2815b4a..0000000
--- a/contents/tests/configuration/include/mockenv.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include "linkerconfig/variables.h"
-
-inline void MockGenericVariables() {
- android::linkerconfig::modules::Variables::AddValue("VNDK_VER", "99");
- android::linkerconfig::modules::Variables::AddValue("PRODUCT", "product");
- android::linkerconfig::modules::Variables::AddValue("SYSTEM_EXT",
- "system_ext");
- android::linkerconfig::modules::Variables::AddValue("LLNDK_LIBRARIES",
- "llndk_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "SANITIZER_RUNTIME_LIBRARIES", "sanitizer_runtime_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "PRIVATE_LLNDK_LIBRARIES", "private_llndk_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "VNDK_SAMEPROCESS_LIBRARIES", "vndk_sameprocess_libraries");
- android::linkerconfig::modules::Variables::AddValue("VNDK_CORE_LIBRARIES",
- "vndk_core_libraries");
- android::linkerconfig::modules::Variables::AddValue(
- "VNDK_USING_CORE_VARIANT_LIBRARIES", "");
-}
-
-inline void MockVndkVersion(std::string vndk_version) {
- android::linkerconfig::modules::Variables::AddValue("VNDK_VER", vndk_version);
-}
-
-inline void MockVndkUsingCoreVariant() {
- android::linkerconfig::modules::Variables::AddValue(
- "VNDK_USING_CORE_VARIANT_LIBRARIES", "vndk_using_core_variant_libraries");
-}
-
-inline void MockVnkdLite() {
- android::linkerconfig::modules::Variables::AddValue("ro.vndk.lite", "true");
-}
\ No newline at end of file
diff --git a/contents/tests/configuration/include/modules.h b/contents/tests/configuration/include/modules.h
deleted file mode 100644
index 998aad0..0000000
--- a/contents/tests/configuration/include/modules.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <map>
-#include <string>
-#include <vector>
-
-// Define basic data structure for linker configuration
-struct Namespace;
-
-struct Link {
- Namespace *from, *to;
- bool allow_all_shared;
- std::vector<std::string> shared_libs;
-};
-
-struct Namespace {
- std::string name;
- bool is_isolated;
- bool is_visible;
- std::vector<std::string> search_path;
- std::vector<std::string> permitted_path;
- std::vector<std::string> asan_search_path;
- std::vector<std::string> asan_permitted_path;
- std::map<std::string, Link> links;
- std::vector<std::string> whitelisted;
-};
-
-struct Section {
- std::string name;
- std::vector<std::string> dirs;
- std::map<std::string, Namespace> namespaces;
-};
-
-struct Configuration {
- std::map<std::string, Section> sections;
-};
-
-template <class K, class V>
-bool MapContainsKey(const std::map<K, V>& map, K key) {
- return map.find(key) != map.end();
-}
\ No newline at end of file
diff --git a/contents/tests/configuration/legacy_test.cc b/contents/tests/configuration/legacy_test.cc
deleted file mode 100644
index 721a8ad..0000000
--- a/contents/tests/configuration/legacy_test.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/legacy.h"
-#include "configurationtest.h"
-#include "linkerconfig/configwriter.h"
-#include "mockenv.h"
-
-TEST(linkerconfig_configuration_fulltest, legacy_test) {
- MockGenericVariables();
- auto legacy_config =
- android::linkerconfig::contents::CreateLegacyConfiguration();
- android::linkerconfig::modules::ConfigWriter config_writer;
-
- legacy_config.WriteConfig(config_writer);
-
- VerifyConfiguration(config_writer.ToString());
-}
\ No newline at end of file
diff --git a/generator/include/linkerconfig/librarylistloader.h b/generator/include/linkerconfig/librarylistloader.h
deleted file mode 100644
index 4f0cd63..0000000
--- a/generator/include/linkerconfig/librarylistloader.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <string>
-
-namespace android {
-namespace linkerconfig {
-namespace generator {
-std::string GetLibrariesString(std::string library_file_path);
-std::string GetPublicLibrariesString(std::string library_file_path,
- std::string private_library_file_path);
-std::string GetPrivateLibrariesString(std::string library_file_path,
- std::string private_library_file_path);
-} // namespace generator
-} // namespace linkerconfig
-} // namespace android
diff --git a/generator/include/linkerconfig/variableloader.h b/generator/include/linkerconfig/variableloader.h
deleted file mode 100644
index b15c5a0..0000000
--- a/generator/include/linkerconfig/variableloader.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <string>
-
-namespace android {
-namespace linkerconfig {
-namespace generator {
-
-void LoadVariables(const std::string& root);
-
-} // namespace generator
-} // namespace linkerconfig
-} // namespace android
diff --git a/generator/librarylistloader.cc b/generator/librarylistloader.cc
deleted file mode 100644
index 33f552e..0000000
--- a/generator/librarylistloader.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/librarylistloader.h"
-
-#include <android-base/result.h>
-#include <android-base/strings.h>
-#include <algorithm>
-#include <fstream>
-#include <iterator>
-#include <set>
-#include <sstream>
-#include <unordered_map>
-
-#include "linkerconfig/log.h"
-
-using LibraryList = std::set<std::string>;
-
-using android::base::ErrnoErrorf;
-using android::base::Result;
-
-namespace {
-std::unordered_map<std::string, LibraryList> library_file_cache;
-Result<LibraryList> GetLibrariesFromFile(std::string file_path) {
- auto cached_data = library_file_cache.find(file_path);
- if (cached_data != library_file_cache.end()) {
- return cached_data->second;
- }
-
- std::string library_name;
- LibraryList library_list;
- std::ifstream library_file(file_path.c_str(), std::ifstream::in);
-
- if (!library_file) {
- return ErrnoErrorf("Failed to open file {}", file_path);
- }
-
- while (std::getline(library_file, library_name)) {
- library_name = android::base::Trim(library_name);
- if (!library_name.empty()) {
- library_list.insert(library_name);
- }
- }
-
- library_file_cache.insert({file_path, library_list});
-
- return library_list;
-}
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace generator {
-std::string GetLibrariesString(std::string library_file_path) {
- auto library_list_result = GetLibrariesFromFile(library_file_path);
- if (library_list_result) {
- return android::base::Join(*library_list_result, ':');
- } else {
- // Consider unavailable library file as empty
- LOG(WARNING) << library_list_result.error();
- return "";
- }
-}
-
-std::string GetPublicLibrariesString(std::string library_file_path,
- std::string private_library_file_path) {
- auto library_list = GetLibrariesFromFile(library_file_path);
- auto private_library_list = GetLibrariesFromFile(private_library_file_path);
-
- if (!library_list) {
- // Consider unavailable library file as empty
- LOG(WARNING) << library_list.error();
- return "";
- }
-
- if (!private_library_list) {
- // No private library found. All libraries are public
- LOG(WARNING) << private_library_list.error();
- return android::base::Join(*library_list, ':');
- }
-
- LibraryList public_library_list;
-
- std::set_difference(
- library_list->begin(),
- library_list->end(),
- private_library_list->begin(),
- private_library_list->end(),
- std::inserter(public_library_list, public_library_list.begin()));
-
- return android::base::Join(public_library_list, ':');
-}
-
-std::string GetPrivateLibrariesString(std::string library_file_path,
- std::string private_library_file_path) {
- auto library_list = GetLibrariesFromFile(library_file_path);
- auto private_library_list = GetLibrariesFromFile(private_library_file_path);
-
- if (!library_list) {
- // Consider unavailable library file as empty
- LOG(WARNING) << library_list.error();
- return "";
- }
-
- if (!private_library_list) {
- // No private library found. All libraries are public
- LOG(WARNING) << private_library_list.error();
- return "";
- }
-
- LibraryList private_only_library_list;
-
- std::set_intersection(library_list->begin(),
- library_list->end(),
- private_library_list->begin(),
- private_library_list->end(),
- std::inserter(private_only_library_list,
- private_only_library_list.begin()));
-
- return android::base::Join(private_only_library_list, ':');
-}
-} // namespace generator
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/generator/tests/data/library_list_a.txt b/generator/tests/data/library_list_a.txt
deleted file mode 100644
index becafad..0000000
--- a/generator/tests/data/library_list_a.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-a.so
-b.so
-c.so
-d.so
-e.so
-f.so
\ No newline at end of file
diff --git a/generator/tests/data/library_list_b.txt b/generator/tests/data/library_list_b.txt
deleted file mode 100644
index ea8f41b..0000000
--- a/generator/tests/data/library_list_b.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-e.so
-f.so
-g.so
-h.so
\ No newline at end of file
diff --git a/generator/tests/data/library_list_c.txt b/generator/tests/data/library_list_c.txt
deleted file mode 100644
index ad80c5a..0000000
--- a/generator/tests/data/library_list_c.txt
+++ /dev/null
@@ -1 +0,0 @@
-
\ No newline at end of file
diff --git a/generator/tests/librarylistloader_test.cc b/generator/tests/librarylistloader_test.cc
deleted file mode 100644
index 00c3c77..0000000
--- a/generator/tests/librarylistloader_test.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <android-base/file.h>
-#include <gtest/gtest.h>
-
-#include "linkerconfig/librarylistloader.h"
-
-using namespace android::linkerconfig::generator;
-
-const std::string kLibraryListA = android::base::GetExecutableDirectory() +
- "/generator/tests/data/library_list_a.txt";
-const std::string kLibraryListB = android::base::GetExecutableDirectory() +
- "/generator/tests/data/library_list_b.txt";
-const std::string kLibraryListC = android::base::GetExecutableDirectory() +
- "/generator/tests/data/library_list_c.txt";
-const std::string kLibraryListInvalid =
- android::base::GetExecutableDirectory() +
- "/generator/tests/data/library_list_invalid.txt";
-
-TEST(linkerconfig_librarylistloader, get_libraries) {
- const auto& library_list = GetLibrariesString(kLibraryListA);
- ASSERT_EQ("a.so:b.so:c.so:d.so:e.so:f.so", library_list);
-
- const auto& library_list_invalid = GetLibrariesString(kLibraryListInvalid);
- ASSERT_TRUE(library_list_invalid.empty());
-
- const auto& library_list_empty = GetLibrariesString(kLibraryListC);
- ASSERT_EQ("", library_list_empty);
-}
-
-TEST(linkerconfig_librarylistloader, get_public_libraries) {
- const auto& public_library_list =
- GetPublicLibrariesString(kLibraryListA, kLibraryListB);
- ASSERT_EQ("a.so:b.so:c.so:d.so", public_library_list);
-
- const auto& all_private_library_list =
- GetPublicLibrariesString(kLibraryListA, kLibraryListA);
- ASSERT_TRUE(all_private_library_list.empty());
-
- const auto& invalid_library_list =
- GetPublicLibrariesString(kLibraryListInvalid, kLibraryListB);
- ASSERT_TRUE(invalid_library_list.empty());
-
- const auto& private_library_invalid_list =
- GetPublicLibrariesString(kLibraryListA, kLibraryListInvalid);
- ASSERT_EQ("a.so:b.so:c.so:d.so:e.so:f.so", private_library_invalid_list);
-
- const auto& empty_library_list =
- GetPublicLibrariesString(kLibraryListC, kLibraryListA);
- ASSERT_EQ("", empty_library_list);
-}
-
-TEST(linkerconfig_librarylistloader, get_private_libraries) {
- const auto& private_library_list =
- GetPrivateLibrariesString(kLibraryListA, kLibraryListB);
- ASSERT_EQ("e.so:f.so", private_library_list);
-
- const auto& all_private_library_list =
- GetPrivateLibrariesString(kLibraryListA, kLibraryListA);
- ASSERT_EQ("a.so:b.so:c.so:d.so:e.so:f.so", all_private_library_list);
-
- const auto& invalid_library_list =
- GetPrivateLibrariesString(kLibraryListInvalid, kLibraryListB);
- ASSERT_TRUE(invalid_library_list.empty());
-
- const auto& private_library_invalid_list =
- GetPrivateLibrariesString(kLibraryListA, kLibraryListInvalid);
- ASSERT_TRUE(private_library_invalid_list.empty());
-}
diff --git a/generator/variableloader.cc b/generator/variableloader.cc
deleted file mode 100644
index 8f6a8a7..0000000
--- a/generator/variableloader.cc
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/variableloader.h"
-
-#include <android-base/result.h>
-#include <climits>
-#include <cstdlib>
-#include <cstring>
-
-#include "linkerconfig/environment.h"
-#include "linkerconfig/librarylistloader.h"
-#include "linkerconfig/log.h"
-#include "linkerconfig/variables.h"
-
-using android::base::ErrnoErrorf;
-using android::base::Result;
-using android::linkerconfig::modules::GetVendorVndkVersion;
-using android::linkerconfig::modules::Variables;
-
-namespace {
-using namespace android::linkerconfig::generator;
-
-void LoadVndkVersionVariable() {
- Variables::AddValue("VNDK_VER", GetVendorVndkVersion());
-}
-
-Result<std::string> GetRealPath(std::string target_path) {
- char resolved_path[PATH_MAX];
- if (realpath(target_path.c_str(), resolved_path) != nullptr) {
- int start_index = 0;
- if (resolved_path[0] == '/') {
- start_index = 1;
- }
- return &resolved_path[start_index];
- }
-
- return ErrnoErrorf("Failed to get realpath from {}", target_path);
-}
-
-void LoadVariableFromPartitionPath(std::string variable_name, std::string path) {
- auto real_path = GetRealPath(path);
-
- if (real_path) {
- Variables::AddValue(variable_name, *real_path);
- } else {
- LOG(WARNING) << real_path.error();
- }
-}
-
-void LoadPartitionPathVariables(const std::string& root) {
- // TODO(b/141714913): generalize path handling
- LoadVariableFromPartitionPath("PRODUCT", root + "/product");
- LoadVariableFromPartitionPath("SYSTEM_EXT", root + "/system_ext");
-}
-
-void LoadLibraryListVariables(const std::string& root) {
- auto private_library_path = root + "/system/etc/vndkprivate.libraries." +
- GetVendorVndkVersion() + ".txt";
- auto llndk_library_path =
- root + "/system/etc/llndk.libraries." + GetVendorVndkVersion() + ".txt";
- auto vndksp_library_path =
- root + "/system/etc/vndksp.libraries." + GetVendorVndkVersion() + ".txt";
- auto vndkcore_library_path = root + "/system/etc/vndkcore.libraries." +
- GetVendorVndkVersion() + ".txt";
- auto vndkcorevariant_library_path = root +
- "/system/etc/vndkcorevariant.libraries." +
- GetVendorVndkVersion() + ".txt";
- auto sanitizer_library_path = root + "/system/etc/sanitizer.libraries.txt";
-
- Variables::AddValue(
- "LLNDK_LIBRARIES",
- GetPublicLibrariesString(llndk_library_path, private_library_path));
-
- Variables::AddValue(
- "PRIVATE_LLNDK_LIBRARIES",
- GetPrivateLibrariesString(llndk_library_path, private_library_path));
-
- Variables::AddValue(
- "VNDK_SAMEPROCESS_LIBRARIES",
- GetPublicLibrariesString(vndksp_library_path, private_library_path));
-
- Variables::AddValue(
- "VNDK_CORE_LIBRARIES",
- GetPublicLibrariesString(vndkcore_library_path, private_library_path));
-
- Variables::AddValue("VNDK_USING_CORE_VARIANT_LIBRARIES",
- GetPublicLibrariesString(vndkcorevariant_library_path,
- private_library_path));
-
- Variables::AddValue("SANITIZER_RUNTIME_LIBRARIES",
- GetLibrariesString(sanitizer_library_path));
-}
-} // namespace
-
-namespace android {
-namespace linkerconfig {
-namespace generator {
-
-void LoadVariables(const std::string& root) {
- LoadVndkVersionVariable();
- LoadPartitionPathVariables(root);
- LoadLibraryListVariables(root);
-}
-
-} // namespace generator
-} // namespace linkerconfig
-} // namespace android
diff --git a/modules/include/linkerconfig/configwriter.h b/include/linkerconfig/configwriter.h
similarity index 94%
rename from modules/include/linkerconfig/configwriter.h
rename to include/linkerconfig/configwriter.h
index 5f93e5f..9bc0f5f 100644
--- a/modules/include/linkerconfig/configwriter.h
+++ b/include/linkerconfig/configwriter.h
@@ -33,6 +33,8 @@
private:
std::stringstream content_;
std::string prefix_;
+
+ std::string ResolveVariables(const std::string& str);
};
} // namespace modules
diff --git a/modules/include/linkerconfig/link.h b/include/linkerconfig/link.h
similarity index 64%
rename from modules/include/linkerconfig/link.h
rename to include/linkerconfig/link.h
index 13c4093..ed8d8a8 100644
--- a/modules/include/linkerconfig/link.h
+++ b/include/linkerconfig/link.h
@@ -22,41 +22,43 @@
#include "linkerconfig/configwriter.h"
#include "linkerconfig/log.h"
+#define LOG_TAG "linkerconfig"
+
namespace android {
namespace linkerconfig {
namespace modules {
class Link {
public:
- Link(std::string origin_namespace, std::string target_namespace)
- : origin_namespace_(std::move(origin_namespace)),
- target_namespace_(std::move(target_namespace)) {
- allow_all_shared_libs_ = false;
+ Link(const std::string& origin_namespace, const std::string& target_namespace,
+ bool allow_all_shared_libs = false)
+ : origin_namespace_(origin_namespace),
+ target_namespace_(target_namespace),
+ allow_all_shared_libs_(allow_all_shared_libs) {
}
- Link(const Link&) = delete;
- Link(Link&&) = default;
-
template <typename T, typename... Args>
void AddSharedLib(T&& lib_name, Args&&... lib_names);
- void AddSharedLib(const std::vector<std::string>& lib_names);
- void AllowAllSharedLibs();
void WriteConfig(ConfigWriter& writer);
private:
const std::string origin_namespace_;
const std::string target_namespace_;
+ const bool allow_all_shared_libs_;
std::vector<std::string> shared_libs_;
- bool allow_all_shared_libs_;
};
template <typename T, typename... Args>
void Link::AddSharedLib(T&& lib_name, Args&&... lib_names) {
- if (!allow_all_shared_libs_) {
- shared_libs_.push_back(std::forward<T>(lib_name));
- if constexpr (sizeof...(Args) > 0) {
- AddSharedLib(std::forward<Args>(lib_names)...);
- }
+ if (allow_all_shared_libs_) {
+ LOG(WARNING) << "Tried to add shared libraries to link from "
+ << origin_namespace_ << " to " << target_namespace_
+ << "while this link is allow_all_shared_libs";
+ return;
+ }
+ shared_libs_.push_back(std::forward<T>(lib_name));
+ if constexpr (sizeof...(Args) > 0) {
+ AddSharedLib(std::forward<Args>(lib_names)...);
}
}
} // namespace modules
} // namespace linkerconfig
-} // namespace android
+} // namespace android
\ No newline at end of file
diff --git a/modules/include/linkerconfig/log.h b/include/linkerconfig/log.h
similarity index 100%
rename from modules/include/linkerconfig/log.h
rename to include/linkerconfig/log.h
diff --git a/include/linkerconfig/namespace.h b/include/linkerconfig/namespace.h
new file mode 100644
index 0000000..3e8c1bf
--- /dev/null
+++ b/include/linkerconfig/namespace.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <map>
+#include <string>
+#include <vector>
+
+#include "linkerconfig/configwriter.h"
+#include "linkerconfig/link.h"
+
+namespace android {
+namespace linkerconfig {
+namespace modules {
+
+class Namespace {
+ public:
+ Namespace(const std::string& name, bool is_isolated = false,
+ bool is_visible = false)
+ : is_isolated_(is_isolated), is_visible_(is_visible), name_(name) {
+ }
+
+ // Add path to search path
+ // This function will add path to namespace.<<namespace>>.search.paths
+ // If also_in_asan is true, this will add path also to
+ // namespace.<<namespace>>.asan.search.paths
+ // If with_data_asan is true when also_in_asan is true,
+ // this will also add asan path starts with /data/asan
+ //
+ // AddSearchPath("/system/${LIB}", false, false) :
+ // namespace.xxx.search.paths += /system/${LIB}
+ // AddSearchPath("/system/${LIB}", true, false) :
+ // namespace.xxx.search.paths += /system/${LIB}
+ // namespace.xxx.asan.search.paths += /system/${LIB}
+ // AddSearchPath("/system/${LIB}", true, true) :
+ // namespace.xxx.search.paths += /system/${LIB}
+ // namespace.xxx.asan.search.paths += /system/${LIB}
+ // namespace.xxx.asan.search.paths += /data/asan/system/${LIB}
+ void AddSearchPath(const std::string& path, bool also_in_asan = true,
+ bool with_data_asan = true);
+
+ // Add path to permitted path
+ // This function will add path to namespace.<<namespace>>.permitted.paths
+ // If also_in_asan is true, this will add path also to
+ // namespace.<<namespace>>.asan.permitted.paths
+ // If with_data_asan is true when also_in_asan is true,
+ // this will also add asan path starts with /data/asan
+ //
+ // AddSearchPath("/system/${LIB}", false, false) :
+ // namespace.xxx.permitted.paths += /system/${LIB}
+ // AddSearchPath("/system/${LIB}", true, false) :
+ // namespace.xxx.permitted.paths += /system/${LIB}
+ // namespace.xxx.asan.permitted.paths += /system/${LIB}
+ // AddSearchPath("/system/${LIB}", true, true) :
+ // namespace.xxx.permitted.paths += /system/${LIB}
+ // namespace.xxx.asan.permitted.paths += /system/${LIB}
+ // namespace.xxx.asan.permitted.paths += /data/asan/system/${LIB}
+ void AddPermittedPath(const std::string& path, bool also_in_asan = true,
+ bool with_data_asan = true);
+ std::shared_ptr<Link> CreateLink(const std::string& target_namespace,
+ bool allow_all_shared_libs = false);
+ void WriteConfig(ConfigWriter& writer);
+
+ private:
+ const bool is_isolated_;
+ const bool is_visible_;
+ const std::string name_;
+ std::vector<std::string> search_paths_;
+ std::vector<std::string> permitted_paths_;
+ std::vector<std::string> asan_search_paths_;
+ std::vector<std::string> asan_permitted_paths_;
+ std::map<std::string, std::shared_ptr<Link>> links_;
+ void WritePathString(ConfigWriter& writer, const std::string& path_type,
+ const std::vector<std::string>& path_list);
+};
+} // namespace modules
+} // namespace linkerconfig
+} // namespace android
\ No newline at end of file
diff --git a/include/linkerconfig/section.h b/include/linkerconfig/section.h
new file mode 100644
index 0000000..b5ac994
--- /dev/null
+++ b/include/linkerconfig/section.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <map>
+#include <memory>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include "linkerconfig/configwriter.h"
+#include "linkerconfig/namespace.h"
+
+namespace android {
+namespace linkerconfig {
+namespace modules {
+class Section {
+ public:
+ Section(const std::string& name) : name_(name) {
+ }
+ template <typename T, typename... Args>
+ void AddBinaryPath(T&& binary_path, Args&&... binary_paths);
+ std::shared_ptr<Namespace> CreateNamespace(const std::string& namespace_name,
+ bool is_isolated = false,
+ bool is_visible = false);
+ void WriteConfig(ConfigWriter& writer);
+ void WriteBinaryPaths(ConfigWriter& writer);
+ std::string GetName();
+
+ private:
+ const std::string name_;
+ std::vector<std::string> binary_paths_;
+ std::map<std::string, std::shared_ptr<Namespace>> namespaces_;
+};
+
+template <typename T, typename... Args>
+void Section::AddBinaryPath(T&& binary_path, Args&&... binary_paths) {
+ binary_paths_.push_back(std::forward<T>(binary_path));
+ if constexpr (sizeof...(Args) > 0) {
+ AddBinaryPath(std::forward<Args>(binary_paths)...);
+ }
+}
+} // namespace modules
+} // namespace linkerconfig
+} // namespace android
\ No newline at end of file
diff --git a/modules/include/linkerconfig/variables.h b/include/linkerconfig/variables.h
similarity index 94%
rename from modules/include/linkerconfig/variables.h
rename to include/linkerconfig/variables.h
index debd7e8..7c2c87f 100644
--- a/modules/include/linkerconfig/variables.h
+++ b/include/linkerconfig/variables.h
@@ -26,7 +26,6 @@
public:
static std::optional<std::string> GetValue(const std::string& key);
static void AddValue(const std::string& key, const std::string& value);
- static std::string ResolveVariables(const std::string& str);
private:
static std::map<std::string, std::string> variables_;
diff --git a/main.cc b/main.cc
deleted file mode 100644
index a721485..0000000
--- a/main.cc
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <getopt.h>
-
-#include <cstring>
-#include <fstream>
-#include <iostream>
-#include <string>
-
-#include "linkerconfig/baseconfig.h"
-#include "linkerconfig/environment.h"
-#include "linkerconfig/legacy.h"
-#include "linkerconfig/log.h"
-#include "linkerconfig/variableloader.h"
-#include "linkerconfig/variables.h"
-
-namespace {
-const static struct option program_options[] = {
- {"target", required_argument, 0, 't'},
-#ifndef __ANROID__
- {"root", required_argument, 0, 'r'},
- {"vndk", required_argument, 0, 'v'},
-#endif
- {"help", no_argument, 0, 'h'},
- {0, 0, 0, 0}};
-
-struct ProgramArgs {
- std::string target_file;
- std::string root;
- std::string vndk_version;
-};
-
-[[noreturn]] void PrintUsage(int status = EXIT_SUCCESS) {
- std::cerr << "Usage : linkerconfig [--target <target_file>]"
-#ifndef __ANDROID__
- " --root <root dir>"
- " --vndk <vndk version>"
-#endif
- " [--help]"
- << std::endl;
- exit(status);
-}
-
-bool ParseArgs(int argc, char* argv[], ProgramArgs* args) {
- int parse_result;
- while ((parse_result = getopt_long(
- argc, argv, "t:r:v:h", program_options, NULL)) != -1) {
- switch (parse_result) {
- case 't':
- args->target_file = optarg;
- break;
- case 'r':
- args->root = optarg;
- break;
- case 'v':
- args->vndk_version = optarg;
- break;
- case 'h':
- PrintUsage();
- default:
- return false;
- }
- }
-
- if (optind < argc) {
- return false;
- }
-
- return true;
-}
-
-android::linkerconfig::modules::Configuration GetConfiguration() {
- if (android::linkerconfig::modules::IsLegacyDevice()) {
- return android::linkerconfig::contents::CreateLegacyConfiguration();
- }
-
- // TODO : Use recovery if needed
-
- // Use base configuration in default
- return android::linkerconfig::contents::CreateBaseConfiguration();
-}
-
-#ifdef __ANDROID__
-struct CombinedLogger {
- android::base::LogdLogger logd;
-
- void operator()(android::base::LogId id, android::base::LogSeverity severity,
- const char* tag, const char* file, unsigned int line,
- const char* message) {
- logd(id, severity, tag, file, line, message);
- KernelLogger(id, severity, tag, file, line, message);
- }
-};
-#endif
-
-} // namespace
-
-int main(int argc, char* argv[]) {
- android::base::InitLogging(argv
-#ifdef __ANDROID__
- ,
- CombinedLogger()
-#endif
- );
-
- ProgramArgs args;
-
- if (!ParseArgs(argc, argv, &args)) {
- PrintUsage(EXIT_FAILURE);
- }
-
- std::ostream* out = &std::cout;
- std::ofstream file_out;
-
- if (args.target_file != "") {
- file_out.open(args.target_file);
- if (file_out.fail()) {
- PLOG(FATAL) << "Failed to open file " << args.target_file;
- return EXIT_FAILURE;
- }
- out = &file_out;
- }
-
-#ifndef __ANDROID__
- if (args.root == "" || args.vndk_version == "") {
- PrintUsage();
- }
- android::linkerconfig::modules::Variables::AddValue("ro.vndk.version",
- args.vndk_version);
-#endif
-
- android::linkerconfig::generator::LoadVariables(args.root);
- auto config = GetConfiguration();
- android::linkerconfig::modules::ConfigWriter config_writer;
-
- config.WriteConfig(config_writer);
- *out << config_writer.ToString();
- if (!out->good()) {
- PLOG(FATAL) << "Failed to write content to " << args.target_file;
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
\ No newline at end of file
diff --git a/modules/configuration.cc b/modules/configuration.cc
deleted file mode 100644
index 555ca99..0000000
--- a/modules/configuration.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/configuration.h"
-
-#include <unordered_map>
-
-#include "linkerconfig/log.h"
-#include "linkerconfig/variables.h"
-
-namespace android {
-namespace linkerconfig {
-namespace modules {
-void Configuration::WriteConfig(ConfigWriter& writer) {
- std::unordered_map<std::string, std::string> resolved_dirs;
-
- for (auto& dir_to_section : dir_to_section_list_) {
- auto resolved_dir = Variables::ResolveVariables(dir_to_section.first);
-
- auto it = resolved_dirs.find(resolved_dir);
-
- if (it != resolved_dirs.end()) {
- LOG(WARNING) << "Binary path " << resolved_dir << " already found from "
- << it->second << ". Path from " << dir_to_section.second
- << " will be ignored.";
- } else {
- resolved_dirs[resolved_dir] = dir_to_section.second;
- writer.WriteLine(
- "dir.%s = %s", dir_to_section.second.c_str(), resolved_dir.c_str());
- }
- }
-
- for (auto& section : sections_) {
- section.WriteConfig(writer);
- }
-}
-
-Section* Configuration::GetSection(const std::string& name) {
- for (auto& section : sections_) {
- if (section.GetName() == name) {
- return §ion;
- }
- }
-
- return nullptr;
-}
-} // namespace modules
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/modules/configwriter.cc b/modules/configwriter.cc
index 0b2db69..aed8abf 100644
--- a/modules/configwriter.cc
+++ b/modules/configwriter.cc
@@ -18,10 +18,16 @@
#include <cstdarg>
#include <cstdio>
+#include <iostream>
+#include <memory>
+#include <regex>
#include "linkerconfig/log.h"
#include "linkerconfig/variables.h"
+constexpr const char* kVariableRegex =
+ "@\\{([^@\\{\\}:]+)(:([^@\\{\\}:]*))?\\}";
+
namespace android {
namespace linkerconfig {
namespace modules {
@@ -63,13 +69,41 @@
}
void ConfigWriter::WriteLine(const std::string& line) {
- auto resolved_line = Variables::ResolveVariables(prefix_ + line);
+ auto resolved_line = ResolveVariables(prefix_ + line);
content_ << resolved_line << std::endl;
}
std::string ConfigWriter::ToString() {
return content_.str();
}
+
+std::string ConfigWriter::ResolveVariables(const std::string& str) {
+ std::string result = str;
+ std::regex variable_regex(kVariableRegex);
+ std::smatch sm;
+
+ while (std::regex_search(result, sm, variable_regex)) {
+ std::stringstream ss;
+ ss << sm.prefix();
+ auto resolved_value = Variables::GetValue(sm[1]);
+ if (resolved_value.has_value()) {
+ ss << resolved_value.value();
+ } else {
+ LOG(WARNING) << "Unable to find value for " << sm[1];
+ bool contains_default = sm[2].length() > 0;
+ if (contains_default) {
+ ss << sm[3];
+ } else {
+ LOG(FATAL) << "There is no default value defined for " << sm[1];
+ }
+ }
+ ss << ResolveVariables(sm.suffix());
+ result = ss.str();
+ }
+
+ return result;
+}
+
} // namespace modules
} // namespace linkerconfig
} // namespace android
\ No newline at end of file
diff --git a/modules/environment.cc b/modules/environment.cc
deleted file mode 100644
index db9c501..0000000
--- a/modules/environment.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "linkerconfig/environment.h"
-#include "linkerconfig/variables.h"
-
-namespace android {
-namespace linkerconfig {
-namespace modules {
-bool IsLegacyDevice() {
- return (!Variables::GetValue("ro.vndk.version").has_value() &&
- !Variables::GetValue("ro.vndk.lite").has_value()) ||
- Variables::GetValue("ro.treble.enabled") == "false";
-}
-
-bool IsVndkLiteDevice() {
- return Variables::GetValue("ro.vndk.lite").value_or("") == "true";
-}
-
-bool IsVndkInSystemNamespace() {
- return Variables::GetValue("VNDK_USING_CORE_VARIANT_LIBRARIES").has_value();
-}
-
-std::string GetVendorVndkVersion() {
- return Variables::GetValue("ro.vndk.version").value_or("");
-}
-} // namespace modules
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/modules/include/linkerconfig/configuration.h b/modules/include/linkerconfig/configuration.h
deleted file mode 100644
index e264f99..0000000
--- a/modules/include/linkerconfig/configuration.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "linkerconfig/configwriter.h"
-#include "linkerconfig/section.h"
-
-namespace android {
-namespace linkerconfig {
-namespace modules {
-using DirToSection = std::pair<std::string, std::string>;
-
-class Configuration {
- public:
- explicit Configuration(std::vector<Section> sections,
- std::vector<DirToSection> dir_to_sections)
- : sections_(std::move(sections)),
- dir_to_section_list_(std::move(dir_to_sections)) {
- }
- Configuration(const Configuration&) = delete;
- Configuration(Configuration&&) = default;
-
- void WriteConfig(ConfigWriter& writer);
-
- // For test usage
- Section* GetSection(const std::string& name);
-
- private:
- std::vector<Section> sections_;
- std::vector<DirToSection> dir_to_section_list_;
-};
-} // namespace modules
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/modules/include/linkerconfig/environment.h b/modules/include/linkerconfig/environment.h
deleted file mode 100644
index 44eecae..0000000
--- a/modules/include/linkerconfig/environment.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <string>
-
-namespace android {
-namespace linkerconfig {
-namespace modules {
-bool IsLegacyDevice();
-bool IsVndkLiteDevice();
-bool IsVndkInSystemNamespace();
-std::string GetVendorVndkVersion();
-} // namespace modules
-} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
diff --git a/modules/include/linkerconfig/namespace.h b/modules/include/linkerconfig/namespace.h
deleted file mode 100644
index 9640b57..0000000
--- a/modules/include/linkerconfig/namespace.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "linkerconfig/configwriter.h"
-#include "linkerconfig/link.h"
-#include "linkerconfig/log.h"
-
-namespace android {
-namespace linkerconfig {
-namespace modules {
-
-/**
- * Explains if the path should be also added for ASAN
- *
- * NONE : the path should not be added for ASAN
- * SAME_PATH : the path should be added for ASAN
- * WITH_DATA_ASAN : the path and /data/asan/<path> should be added for ASAN
- */
-enum class AsanPath {
- NONE,
- SAME_PATH,
- WITH_DATA_ASAN,
-};
-
-class Namespace {
- public:
- explicit Namespace(std::string name, bool is_isolated = false,
- bool is_visible = false)
- : is_isolated_(is_isolated),
- is_visible_(is_visible),
- name_(std::move(name)) {
- }
-
- Namespace(const Namespace& ns) = delete;
- Namespace(Namespace&& ns) = default;
-
- // Add path to search path
- // This function will add path to namespace.<<namespace>>.search.paths
- // If path_from_asan is SAME_PATH, this will add path also to
- // namespace.<<namespace>>.asan.search.paths
- // If path_from_asan is WITH_DATA_ASAN,
- // this will also add asan path starts with /data/asan
- //
- // AddSearchPath("/system/${LIB}", AsanPath::NONE) :
- // namespace.xxx.search.paths += /system/${LIB}
- // AddSearchPath("/system/${LIB}", AsanPath::SAME_PATH) :
- // namespace.xxx.search.paths += /system/${LIB}
- // namespace.xxx.asan.search.paths += /system/${LIB}
- // AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN) :
- // namespace.xxx.search.paths += /system/${LIB}
- // namespace.xxx.asan.search.paths += /data/asan/system/${LIB}
- // namespace.xxx.asan.search.paths += /system/${LIB}
- void AddSearchPath(const std::string& path,
- AsanPath path_from_asan = AsanPath::SAME_PATH);
-
- // Add path to permitted path
- // This function will add path to namespace.<<namespace>>.permitted.paths
- // If path_from_asan is SAME_PATH, this will add path also to
- // namespace.<<namespace>>.asan.permitted.paths
- // If path_from_asan is WITH_DATA_ASAN,
- // this will also add asan path starts with /data/asan
- //
- // AddSearchPath("/system/${LIB}", AsanPath::NONE) :
- // namespace.xxx.permitted.paths += /system/${LIB}
- // AddSearchPath("/system/${LIB}", AsanPath::SAME_PATH) :
- // namespace.xxx.permitted.paths += /system/${LIB}
- // namespace.xxx.asan.permitted.paths += /system/${LIB}
- // AddSearchPath("/system/${LIB}", AsanPath::WITH_DATA_ASAN) :
- // namespace.xxx.permitted.paths += /system/${LIB}
- // namespace.xxx.asan.permitted.paths += /data/asan/system/${LIB}
- // namespace.xxx.asan.permitted.paths += /system/${LIB}
- void AddPermittedPath(const std::string& path,
- AsanPath path_from_asan = AsanPath::SAME_PATH);
-
- // Returns a link from this namespace to the given one. If one already exists
- // it is returned, otherwise one is created.
- Link& GetLink(const std::string& target_namespace);
-
- void WriteConfig(ConfigWriter& writer);
- void AddWhitelisted(const std::string& path);
-
- std::string GetName();
-
- // For test usage
- bool ContainsSearchPath(const std::string& path, AsanPath path_from_asan);
- bool ContainsPermittedPath(const std::string& path, AsanPath path_from_asan);
-
- private:
- const bool is_isolated_;
- const bool is_visible_;
- const std::string name_;
- std::vector<std::string> search_paths_;
- std::vector<std::string> permitted_paths_;
- std::vector<std::string> asan_search_paths_;
- std::vector<std::string> asan_permitted_paths_;
- std::vector<std::string> whitelisted_;
- std::map<std::string, Link> links_;
- void WritePathString(ConfigWriter& writer, const std::string& path_type,
- const std::vector<std::string>& path_list);
-};
-} // namespace modules
-} // namespace linkerconfig
-} // namespace android
diff --git a/modules/include/linkerconfig/section.h b/modules/include/linkerconfig/section.h
deleted file mode 100644
index 4d9aee3..0000000
--- a/modules/include/linkerconfig/section.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#pragma once
-
-#include <map>
-#include <string>
-#include <utility>
-#include <vector>
-
-#include "linkerconfig/configwriter.h"
-#include "linkerconfig/namespace.h"
-
-namespace android {
-namespace linkerconfig {
-namespace modules {
-
-class Section {
- public:
- Section(std::string name, std::vector<Namespace> namespaces)
- : name_(std::move(name)), namespaces_(std::move(namespaces)) {
- }
-
- Section(const Section&) = delete;
- Section(Section&&) = default;
-
- void WriteConfig(ConfigWriter& writer);
- std::vector<std::string> GetBinaryPaths();
- std::string GetName();
-
- Namespace* GetNamespace(const std::string& namespace_name);
-
- template <class _Function>
- void ForEachNamespaces(_Function f) {
- for (auto& ns : namespaces_) {
- f(ns);
- }
- }
-
- private:
- const std::string name_;
- std::vector<Namespace> namespaces_;
-};
-} // namespace modules
-} // namespace linkerconfig
-} // namespace android
diff --git a/modules/link.cc b/modules/link.cc
index 19569ae..64dddda 100644
--- a/modules/link.cc
+++ b/modules/link.cc
@@ -19,40 +19,22 @@
namespace android {
namespace linkerconfig {
namespace modules {
-
-void Link::AddSharedLib(const std::vector<std::string>& lib_names) {
- if (!allow_all_shared_libs_) {
- shared_libs_.insert(shared_libs_.end(), lib_names.begin(), lib_names.end());
- }
-}
-
-void Link::AllowAllSharedLibs() {
- if (!allow_all_shared_libs_) {
- shared_libs_.clear();
- allow_all_shared_libs_ = true;
- }
-}
-
void Link::WriteConfig(ConfigWriter& writer) {
writer.SetPrefix("namespace." + origin_namespace_ + ".link." +
target_namespace_);
if (allow_all_shared_libs_) {
writer.WriteLine(".allow_all_shared_libs = true");
- } else if (!shared_libs_.empty()) {
+ } else {
bool is_first = true;
for (auto& lib_name : shared_libs_) {
- writer.WriteLine(
- ".shared_libs %s %s", is_first ? "=" : "+=", lib_name.c_str());
+ writer.WriteLine(".shared_libs %s %s",
+ is_first ? "=" : "+=", lib_name.c_str());
is_first = false;
}
- } else {
- LOG(WARNING) << "Ignored empty shared libs link from " << origin_namespace_
- << " to " << target_namespace_;
}
writer.ResetPrefix();
}
-
} // namespace modules
} // namespace linkerconfig
-} // namespace android
+} // namespace android
\ No newline at end of file
diff --git a/modules/namespace.cc b/modules/namespace.cc
index 7588c84..486691c 100644
--- a/modules/namespace.cc
+++ b/modules/namespace.cc
@@ -16,22 +16,9 @@
#include "linkerconfig/namespace.h"
-#include <android-base/strings.h>
-
#include "linkerconfig/log.h"
-namespace {
-bool FindFromPathList(const std::vector<std::string>& list,
- const std::string& path) {
- for (auto& path_member : list) {
- for (auto& path_item : android::base::Split(path_member, ":")) {
- if (path_item == path) return true;
- }
- }
-
- return false;
-}
-} // namespace
+#define LOG_TAG "linkerconfig"
namespace android {
namespace linkerconfig {
@@ -50,10 +37,18 @@
}
}
-Link& Namespace::GetLink(const std::string& target_namespace) {
- auto iter =
- links_.try_emplace(target_namespace, name_, target_namespace).first;
- return iter->second;
+std::shared_ptr<Link> Namespace::CreateLink(const std::string& target_namespace,
+ bool allow_all_shared_libs) {
+ auto new_link =
+ std::make_shared<Link>(name_, target_namespace, allow_all_shared_libs);
+
+ if (links_.find(target_namespace) != links_.end()) {
+ LOG(INFO) << "Link to " << target_namespace
+ << " already exists. Overwriting link.";
+ }
+
+ links_[target_namespace] = new_link;
+ return new_link;
}
void Namespace::WriteConfig(ConfigWriter& writer) {
@@ -70,17 +65,10 @@
WritePathString(writer, "asan.search", asan_search_paths_);
WritePathString(writer, "asan.permitted", asan_permitted_paths_);
- bool is_first = true;
- for (const auto& whitelisted : whitelisted_) {
- writer.WriteLine(
- "whitelisted %s %s", is_first ? "=" : "+=", whitelisted.c_str());
- is_first = false;
- }
-
if (!links_.empty()) {
std::string link_list = "";
- is_first = true;
+ bool is_first = true;
for (auto& link : links_) {
if (!is_first) {
link_list += ",";
@@ -92,70 +80,37 @@
writer.WriteLine("links = " + link_list);
for (auto& link : links_) {
- link.second.WriteConfig(writer);
+ link.second->WriteConfig(writer);
}
}
writer.ResetPrefix();
}
-void Namespace::AddSearchPath(const std::string& path, AsanPath path_from_asan) {
+void Namespace::AddSearchPath(const std::string& path, bool in_asan,
+ bool with_data_asan) {
search_paths_.push_back(path);
- switch (path_from_asan) {
- case AsanPath::NONE:
- break;
- case AsanPath::SAME_PATH:
- asan_search_paths_.push_back(path);
- break;
- case AsanPath::WITH_DATA_ASAN:
+ if (in_asan) {
+ asan_search_paths_.push_back(path);
+ if (with_data_asan) {
asan_search_paths_.push_back(kDataAsanPath + path);
- asan_search_paths_.push_back(path);
- break;
+ }
}
}
-void Namespace::AddPermittedPath(const std::string& path,
- AsanPath path_from_asan) {
+void Namespace::AddPermittedPath(const std::string& path, bool in_asan,
+ bool with_data_asan) {
permitted_paths_.push_back(path);
- switch (path_from_asan) {
- case AsanPath::NONE:
- break;
- case AsanPath::SAME_PATH:
- asan_permitted_paths_.push_back(path);
- break;
- case AsanPath::WITH_DATA_ASAN:
+ if (in_asan) {
+ asan_permitted_paths_.push_back(path);
+ if (with_data_asan) {
asan_permitted_paths_.push_back(kDataAsanPath + path);
- asan_permitted_paths_.push_back(path);
- break;
+ }
}
}
-void Namespace::AddWhitelisted(const std::string& path) {
- whitelisted_.push_back(path);
-}
-
-std::string Namespace::GetName() {
- return name_;
-}
-
-bool Namespace::ContainsSearchPath(const std::string& path,
- AsanPath path_from_asan) {
- return FindFromPathList(search_paths_, path) &&
- (path_from_asan == AsanPath::NONE ||
- FindFromPathList(asan_search_paths_, path)) &&
- (path_from_asan != AsanPath::WITH_DATA_ASAN ||
- FindFromPathList(asan_search_paths_, kDataAsanPath + path));
-}
-bool Namespace::ContainsPermittedPath(const std::string& path,
- AsanPath path_from_asan) {
- return FindFromPathList(permitted_paths_, path) &&
- (path_from_asan == AsanPath::NONE ||
- FindFromPathList(asan_permitted_paths_, path)) &&
- (path_from_asan != AsanPath::WITH_DATA_ASAN ||
- FindFromPathList(asan_permitted_paths_, kDataAsanPath + path));
-}
} // namespace modules
} // namespace linkerconfig
-} // namespace android
+} // namespace android
\ No newline at end of file
diff --git a/modules/section.cc b/modules/section.cc
index 6929c43..98c3a94 100644
--- a/modules/section.cc
+++ b/modules/section.cc
@@ -16,9 +16,27 @@
#include "linkerconfig/section.h"
+#include "linkerconfig/log.h"
+
+#define LOG_TAG "linkerconfig"
+
namespace android {
namespace linkerconfig {
namespace modules {
+std::shared_ptr<Namespace> Section::CreateNamespace(
+ const std::string& namespace_name, bool is_isolated, bool is_visible) {
+ auto new_namespace =
+ std::make_shared<Namespace>(namespace_name, is_isolated, is_visible);
+
+ if (namespaces_.find(namespace_name) != namespaces_.end()) {
+ LOG(INFO) << "Namespace " << namespace_name
+ << " already exists. Overwriting namespace.";
+ }
+
+ namespaces_[namespace_name] = new_namespace;
+ return new_namespace;
+}
+
void Section::WriteConfig(ConfigWriter& writer) {
writer.WriteLine("[%s]", name_.c_str());
@@ -26,12 +44,12 @@
bool is_first = true;
for (auto& ns : namespaces_) {
- if (ns.GetName() != "default") {
+ if (ns.first != "default") {
if (!is_first) {
additional_namespaces += ",";
}
- additional_namespaces += ns.GetName();
+ additional_namespaces += ns.first;
is_first = false;
}
}
@@ -41,18 +59,18 @@
}
for (auto& ns : namespaces_) {
- ns.WriteConfig(writer);
+ ns.second->WriteConfig(writer);
}
}
-Namespace* Section::GetNamespace(const std::string& namespace_name) {
- for (auto& ns : namespaces_) {
- if (ns.GetName() == namespace_name) {
- return &ns;
- }
+void Section::WriteBinaryPaths(ConfigWriter& writer) {
+ writer.SetPrefix("dir." + name_ + " = ");
+
+ for (auto& path : binary_paths_) {
+ writer.WriteLine(path);
}
- return nullptr;
+ writer.ResetPrefix();
}
std::string Section::GetName() {
diff --git a/modules/tests/configuration_test.cc b/modules/tests/configuration_test.cc
deleted file mode 100644
index abd2505..0000000
--- a/modules/tests/configuration_test.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include <vector>
-
-#include "linkerconfig/configuration.h"
-#include "linkerconfig/variables.h"
-#include "modules_testbase.h"
-
-using namespace android::linkerconfig::modules;
-
-constexpr const char* kExpectedConfiguration =
- R"(dir.system = /system/bin
-dir.system = /system/xbin
-dir.system = /product/bin
-dir.vendor = /odm/bin
-dir.vendor = /vendor/bin
-dir.vendor = /system/bin/vendor
-dir.vendor = /product/bin/vendor
-[system]
-additional.namespaces = namespace1,namespace2
-namespace.default.isolated = false
-namespace.default.search.paths = /search_path1
-namespace.default.search.paths += /search_path2
-namespace.default.search.paths += /search_path3
-namespace.default.permitted.paths = /permitted_path1
-namespace.default.permitted.paths += /permitted_path2
-namespace.default.permitted.paths += /permitted_path3
-namespace.default.asan.search.paths = /data/asan/search_path1
-namespace.default.asan.search.paths += /search_path1
-namespace.default.asan.search.paths += /search_path2
-namespace.default.asan.permitted.paths = /data/asan/permitted_path1
-namespace.default.asan.permitted.paths += /permitted_path1
-namespace.default.asan.permitted.paths += /permitted_path2
-namespace.default.links = namespace1,namespace2
-namespace.default.link.namespace1.shared_libs = lib1.so
-namespace.default.link.namespace1.shared_libs += lib2.so
-namespace.default.link.namespace1.shared_libs += lib3.so
-namespace.default.link.namespace2.allow_all_shared_libs = true
-namespace.namespace1.isolated = false
-namespace.namespace1.search.paths = /search_path1
-namespace.namespace1.search.paths += /search_path2
-namespace.namespace1.search.paths += /search_path3
-namespace.namespace1.permitted.paths = /permitted_path1
-namespace.namespace1.permitted.paths += /permitted_path2
-namespace.namespace1.permitted.paths += /permitted_path3
-namespace.namespace1.asan.search.paths = /data/asan/search_path1
-namespace.namespace1.asan.search.paths += /search_path1
-namespace.namespace1.asan.search.paths += /search_path2
-namespace.namespace1.asan.permitted.paths = /data/asan/permitted_path1
-namespace.namespace1.asan.permitted.paths += /permitted_path1
-namespace.namespace1.asan.permitted.paths += /permitted_path2
-namespace.namespace2.isolated = false
-namespace.namespace2.search.paths = /search_path1
-namespace.namespace2.search.paths += /search_path2
-namespace.namespace2.search.paths += /search_path3
-namespace.namespace2.permitted.paths = /permitted_path1
-namespace.namespace2.permitted.paths += /permitted_path2
-namespace.namespace2.permitted.paths += /permitted_path3
-namespace.namespace2.asan.search.paths = /data/asan/search_path1
-namespace.namespace2.asan.search.paths += /search_path1
-namespace.namespace2.asan.search.paths += /search_path2
-namespace.namespace2.asan.permitted.paths = /data/asan/permitted_path1
-namespace.namespace2.asan.permitted.paths += /permitted_path1
-namespace.namespace2.asan.permitted.paths += /permitted_path2
-[vendor]
-namespace.default.isolated = false
-namespace.default.search.paths = /search_path1
-namespace.default.search.paths += /search_path2
-namespace.default.search.paths += /search_path3
-namespace.default.permitted.paths = /permitted_path1
-namespace.default.permitted.paths += /permitted_path2
-namespace.default.permitted.paths += /permitted_path3
-namespace.default.asan.search.paths = /data/asan/search_path1
-namespace.default.asan.search.paths += /search_path1
-namespace.default.asan.search.paths += /search_path2
-namespace.default.asan.permitted.paths = /data/asan/permitted_path1
-namespace.default.asan.permitted.paths += /permitted_path1
-namespace.default.asan.permitted.paths += /permitted_path2
-)";
-
-TEST(linkerconfig_configuration, generate_configuration) {
- Variables::AddValue("PRODUCT", "product");
- std::vector<Section> sections;
-
- std::vector<DirToSection> dir_to_sections = {
- {"/system/bin", "system"},
- {"/system/xbin", "system"},
- {"/@{PRODUCT}/bin", "system"},
- {"/odm/bin", "vendor"},
- {"/vendor/bin", "vendor"},
- {"/system/bin/vendor", "vendor"},
- {"/product/bin/vendor", "vendor"},
- {"/product/bin", "vendor"},
- };
-
- std::vector<Namespace> system_namespaces;
-
- system_namespaces.emplace_back(CreateNamespaceWithLinks(
- "default", false, false, "namespace1", "namespace2"));
- system_namespaces.emplace_back(
- CreateNamespaceWithPaths("namespace1", false, false));
- system_namespaces.emplace_back(
- CreateNamespaceWithPaths("namespace2", false, false));
-
- Section system_section("system", std::move(system_namespaces));
- sections.emplace_back(std::move(system_section));
-
- std::vector<Namespace> vendor_namespaces;
-
- vendor_namespaces.emplace_back(
- CreateNamespaceWithPaths("default", false, false));
-
- Section vendor_section("vendor", std::move(vendor_namespaces));
- sections.emplace_back(std::move(vendor_section));
-
- Configuration conf(std::move(sections), dir_to_sections);
-
- android::linkerconfig::modules::ConfigWriter writer;
- conf.WriteConfig(writer);
-
- ASSERT_EQ(kExpectedConfiguration, writer.ToString());
-}
\ No newline at end of file
diff --git a/modules/tests/link_test.cc b/modules/tests/link_test.cc
index c73e533..a467ba4 100644
--- a/modules/tests/link_test.cc
+++ b/modules/tests/link_test.cc
@@ -29,8 +29,7 @@
android::linkerconfig::modules::ConfigWriter writer;
auto link = std::make_shared<android::linkerconfig::modules::Link>(
- "originalNamespace", "targetNamespace");
- link->AllowAllSharedLibs();
+ "originalNamespace", "targetNamespace", true);
link->WriteConfig(writer);
auto config_text = writer.ToString();
@@ -50,4 +49,4 @@
auto config_text = writer.ToString();
ASSERT_EQ(config_text, kSharedLibsExpectedResult);
-}
+}
\ No newline at end of file
diff --git a/modules/tests/modules_testbase.h b/modules/tests/modules_testbase.h
index 22f791a..7974416 100644
--- a/modules/tests/modules_testbase.h
+++ b/modules/tests/modules_testbase.h
@@ -15,30 +15,25 @@
*/
#pragma once
+#include <memory>
+
#include "linkerconfig/namespace.h"
-using namespace android::linkerconfig::modules;
-
-inline Namespace CreateNamespaceWithPaths(std::string name, bool is_isolated,
- bool is_visible) {
- Namespace ns(name, is_isolated, is_visible);
- ns.AddSearchPath("/search_path1", AsanPath::WITH_DATA_ASAN);
- ns.AddSearchPath("/search_path2", AsanPath::SAME_PATH);
- ns.AddSearchPath("/search_path3", AsanPath::NONE);
- ns.AddPermittedPath("/permitted_path1", AsanPath::WITH_DATA_ASAN);
- ns.AddPermittedPath("/permitted_path2", AsanPath::SAME_PATH);
- ns.AddPermittedPath("/permitted_path3", AsanPath::NONE);
-
- return ns;
+inline void DecorateNamespaceWithPaths(
+ std::shared_ptr<android::linkerconfig::modules::Namespace> ns) {
+ ns->AddSearchPath("/search_path1");
+ ns->AddSearchPath("/search_path2", true, false);
+ ns->AddSearchPath("/search_path3", false, false);
+ ns->AddPermittedPath("/permitted_path1");
+ ns->AddPermittedPath("/permitted_path2", true, false);
+ ns->AddPermittedPath("/permitted_path3", false, false);
}
-inline Namespace CreateNamespaceWithLinks(std::string name, bool is_isolated,
- bool is_visible, std::string target_1,
- std::string target_2) {
- Namespace ns = CreateNamespaceWithPaths(name, is_isolated, is_visible);
- auto& link = ns.GetLink(target_1);
- link.AddSharedLib("lib1.so", "lib2.so", "lib3.so");
+inline void DecorateNamespaceWithLinks(
+ std::shared_ptr<android::linkerconfig::modules::Namespace> ns,
+ std::string target_1, std::string target_2) {
+ auto link = ns->CreateLink(target_1, false);
+ link->AddSharedLib("lib1.so", "lib2.so", "lib3.so");
- ns.GetLink(target_2).AllowAllSharedLibs();
- return ns;
-}
+ ns->CreateLink(target_2, true);
+}
\ No newline at end of file
diff --git a/modules/tests/namespace_test.cc b/modules/tests/namespace_test.cc
index 6fb274b..777d8d7 100644
--- a/modules/tests/namespace_test.cc
+++ b/modules/tests/namespace_test.cc
@@ -27,11 +27,11 @@
namespace.test_namespace.permitted.paths = /permitted_path1
namespace.test_namespace.permitted.paths += /permitted_path2
namespace.test_namespace.permitted.paths += /permitted_path3
-namespace.test_namespace.asan.search.paths = /data/asan/search_path1
-namespace.test_namespace.asan.search.paths += /search_path1
+namespace.test_namespace.asan.search.paths = /search_path1
+namespace.test_namespace.asan.search.paths += /data/asan/search_path1
namespace.test_namespace.asan.search.paths += /search_path2
-namespace.test_namespace.asan.permitted.paths = /data/asan/permitted_path1
-namespace.test_namespace.asan.permitted.paths += /permitted_path1
+namespace.test_namespace.asan.permitted.paths = /permitted_path1
+namespace.test_namespace.asan.permitted.paths += /data/asan/permitted_path1
namespace.test_namespace.asan.permitted.paths += /permitted_path2
)";
@@ -44,11 +44,11 @@
namespace.test_namespace.permitted.paths = /permitted_path1
namespace.test_namespace.permitted.paths += /permitted_path2
namespace.test_namespace.permitted.paths += /permitted_path3
-namespace.test_namespace.asan.search.paths = /data/asan/search_path1
-namespace.test_namespace.asan.search.paths += /search_path1
+namespace.test_namespace.asan.search.paths = /search_path1
+namespace.test_namespace.asan.search.paths += /data/asan/search_path1
namespace.test_namespace.asan.search.paths += /search_path2
-namespace.test_namespace.asan.permitted.paths = /data/asan/permitted_path1
-namespace.test_namespace.asan.permitted.paths += /permitted_path1
+namespace.test_namespace.asan.permitted.paths = /permitted_path1
+namespace.test_namespace.asan.permitted.paths += /data/asan/permitted_path1
namespace.test_namespace.asan.permitted.paths += /permitted_path2
namespace.test_namespace.links = target_namespace1,target_namespace2
namespace.test_namespace.link.target_namespace1.shared_libs = lib1.so
@@ -57,28 +57,13 @@
namespace.test_namespace.link.target_namespace2.allow_all_shared_libs = true
)";
-constexpr const char* kExpectedNamespaceWithWhitelisted =
- R"(namespace.test_namespace.isolated = false
-namespace.test_namespace.search.paths = /search_path1
-namespace.test_namespace.search.paths += /search_path2
-namespace.test_namespace.search.paths += /search_path3
-namespace.test_namespace.permitted.paths = /permitted_path1
-namespace.test_namespace.permitted.paths += /permitted_path2
-namespace.test_namespace.permitted.paths += /permitted_path3
-namespace.test_namespace.asan.search.paths = /data/asan/search_path1
-namespace.test_namespace.asan.search.paths += /search_path1
-namespace.test_namespace.asan.search.paths += /search_path2
-namespace.test_namespace.asan.permitted.paths = /data/asan/permitted_path1
-namespace.test_namespace.asan.permitted.paths += /permitted_path1
-namespace.test_namespace.asan.permitted.paths += /permitted_path2
-namespace.test_namespace.whitelisted = whitelisted_path1
-namespace.test_namespace.whitelisted += whitelisted_path2
-)";
-
TEST(linkerconfig_namespace, simple_namespace) {
android::linkerconfig::modules::ConfigWriter writer;
- auto ns = CreateNamespaceWithPaths("test_namespace", false, false);
- ns.WriteConfig(writer);
+ auto ns = std::make_shared<android::linkerconfig::modules::Namespace>(
+ "test_namespace");
+
+ DecorateNamespaceWithPaths(ns);
+ ns->WriteConfig(writer);
auto config = writer.ToString();
ASSERT_EQ(config, kExpectedSimpleNamespaceConfig);
@@ -86,23 +71,14 @@
TEST(linkerconfig_namespace, namespace_with_links) {
android::linkerconfig::modules::ConfigWriter writer;
+ auto ns = std::make_shared<android::linkerconfig::modules::Namespace>(
+ "test_namespace", /*is_isolated*/ true,
+ /*is_visible*/ true);
- auto ns = CreateNamespaceWithLinks("test_namespace", true, true,
- "target_namespace1", "target_namespace2");
- ns.WriteConfig(writer);
+ DecorateNamespaceWithPaths(ns);
+ DecorateNamespaceWithLinks(ns, "target_namespace1", "target_namespace2");
+ ns->WriteConfig(writer);
auto config = writer.ToString();
ASSERT_EQ(config, kExpectedNamespaceWithLinkConfig);
-}
-
-TEST(linkerconfig_namespace, namespace_with_whitelisted) {
- android::linkerconfig::modules::ConfigWriter writer;
- auto ns = CreateNamespaceWithPaths("test_namespace", false, false);
- ns.AddWhitelisted("whitelisted_path1");
- ns.AddWhitelisted("whitelisted_path2");
- ns.WriteConfig(writer);
-
- auto config = writer.ToString();
-
- ASSERT_EQ(config, kExpectedNamespaceWithWhitelisted);
}
\ No newline at end of file
diff --git a/modules/tests/section_test.cc b/modules/tests/section_test.cc
index 854c3c0..bba62a4 100644
--- a/modules/tests/section_test.cc
+++ b/modules/tests/section_test.cc
@@ -20,8 +20,6 @@
#include "linkerconfig/section.h"
#include "modules_testbase.h"
-using namespace android::linkerconfig::modules;
-
constexpr const char* kSectionWithNamespacesExpectedResult =
R"([test_section]
additional.namespaces = namespace1,namespace2
@@ -33,11 +31,11 @@
namespace.default.permitted.paths = /permitted_path1
namespace.default.permitted.paths += /permitted_path2
namespace.default.permitted.paths += /permitted_path3
-namespace.default.asan.search.paths = /data/asan/search_path1
-namespace.default.asan.search.paths += /search_path1
+namespace.default.asan.search.paths = /search_path1
+namespace.default.asan.search.paths += /data/asan/search_path1
namespace.default.asan.search.paths += /search_path2
-namespace.default.asan.permitted.paths = /data/asan/permitted_path1
-namespace.default.asan.permitted.paths += /permitted_path1
+namespace.default.asan.permitted.paths = /permitted_path1
+namespace.default.asan.permitted.paths += /data/asan/permitted_path1
namespace.default.asan.permitted.paths += /permitted_path2
namespace.default.links = namespace1,namespace2
namespace.default.link.namespace1.shared_libs = lib1.so
@@ -51,11 +49,11 @@
namespace.namespace1.permitted.paths = /permitted_path1
namespace.namespace1.permitted.paths += /permitted_path2
namespace.namespace1.permitted.paths += /permitted_path3
-namespace.namespace1.asan.search.paths = /data/asan/search_path1
-namespace.namespace1.asan.search.paths += /search_path1
+namespace.namespace1.asan.search.paths = /search_path1
+namespace.namespace1.asan.search.paths += /data/asan/search_path1
namespace.namespace1.asan.search.paths += /search_path2
-namespace.namespace1.asan.permitted.paths = /data/asan/permitted_path1
-namespace.namespace1.asan.permitted.paths += /permitted_path1
+namespace.namespace1.asan.permitted.paths = /permitted_path1
+namespace.namespace1.asan.permitted.paths += /data/asan/permitted_path1
namespace.namespace1.asan.permitted.paths += /permitted_path2
namespace.namespace1.links = default,namespace2
namespace.namespace1.link.default.shared_libs = lib1.so
@@ -69,11 +67,11 @@
namespace.namespace2.permitted.paths = /permitted_path1
namespace.namespace2.permitted.paths += /permitted_path2
namespace.namespace2.permitted.paths += /permitted_path3
-namespace.namespace2.asan.search.paths = /data/asan/search_path1
-namespace.namespace2.asan.search.paths += /search_path1
+namespace.namespace2.asan.search.paths = /search_path1
+namespace.namespace2.asan.search.paths += /data/asan/search_path1
namespace.namespace2.asan.search.paths += /search_path2
-namespace.namespace2.asan.permitted.paths = /data/asan/permitted_path1
-namespace.namespace2.asan.permitted.paths += /permitted_path1
+namespace.namespace2.asan.permitted.paths = /permitted_path1
+namespace.namespace2.asan.permitted.paths += /data/asan/permitted_path1
namespace.namespace2.asan.permitted.paths += /permitted_path2
)";
@@ -86,40 +84,58 @@
namespace.default.permitted.paths = /permitted_path1
namespace.default.permitted.paths += /permitted_path2
namespace.default.permitted.paths += /permitted_path3
-namespace.default.asan.search.paths = /data/asan/search_path1
-namespace.default.asan.search.paths += /search_path1
+namespace.default.asan.search.paths = /search_path1
+namespace.default.asan.search.paths += /data/asan/search_path1
namespace.default.asan.search.paths += /search_path2
-namespace.default.asan.permitted.paths = /data/asan/permitted_path1
-namespace.default.asan.permitted.paths += /permitted_path1
+namespace.default.asan.permitted.paths = /permitted_path1
+namespace.default.asan.permitted.paths += /data/asan/permitted_path1
namespace.default.asan.permitted.paths += /permitted_path2
)";
+constexpr const char* kSectionBinaryPathExpectedResult =
+ R"(dir.test_section = binary_path1
+dir.test_section = binary_path2
+dir.test_section = binary_path3
+)";
+
TEST(linkerconfig_section, section_with_namespaces) {
- ConfigWriter writer;
+ android::linkerconfig::modules::ConfigWriter writer;
+ android::linkerconfig::modules::Section section("test_section");
- std::vector<Namespace> namespaces;
+ auto default_namespace = section.CreateNamespace(
+ "default", /*is_isolated*/ true, /*is_visible*/ true);
+ DecorateNamespaceWithPaths(default_namespace);
+ DecorateNamespaceWithLinks(default_namespace, "namespace1", "namespace2");
- namespaces.emplace_back(CreateNamespaceWithLinks("default", true, true,
- "namespace1", "namespace2"));
- namespaces.emplace_back(CreateNamespaceWithLinks("namespace1", false, false,
- "default", "namespace2"));
- namespaces.emplace_back(CreateNamespaceWithPaths("namespace2", false, false));
+ auto namespace1 = section.CreateNamespace("namespace1");
+ DecorateNamespaceWithPaths(namespace1);
+ DecorateNamespaceWithLinks(namespace1, "default", "namespace2");
- Section section("test_section", std::move(namespaces));
+ auto namespace2 = section.CreateNamespace("namespace2");
+ DecorateNamespaceWithPaths(namespace2);
section.WriteConfig(writer);
auto config = writer.ToString();
- ASSERT_EQ(kSectionWithNamespacesExpectedResult, config);
+ ASSERT_EQ(config, kSectionWithNamespacesExpectedResult);
}
TEST(linkerconfig_section, section_with_one_namespace) {
android::linkerconfig::modules::ConfigWriter writer;
+ android::linkerconfig::modules::Section section("test_section");
+ auto ns = section.CreateNamespace("default");
+ DecorateNamespaceWithPaths(ns);
- std::vector<Namespace> namespaces;
- namespaces.emplace_back(CreateNamespaceWithPaths("default", false, false));
-
- Section section("test_section", std::move(namespaces));
section.WriteConfig(writer);
auto config = writer.ToString();
- ASSERT_EQ(kSectionWithOneNamespaceExpectedResult, config);
+ ASSERT_EQ(config, kSectionWithOneNamespaceExpectedResult);
+}
+
+TEST(linkerconfig_section, binary_paths) {
+ android::linkerconfig::modules::ConfigWriter writer;
+ android::linkerconfig::modules::Section section("test_section");
+ section.AddBinaryPath("binary_path1", "binary_path2", "binary_path3");
+
+ section.WriteBinaryPaths(writer);
+ auto binary_paths = writer.ToString();
+ ASSERT_EQ(binary_paths, kSectionBinaryPathExpectedResult);
}
\ No newline at end of file
diff --git a/modules/tests/variables_test.cc b/modules/tests/variables_test.cc
index 3b58ec2..e4ada44 100644
--- a/modules/tests/variables_test.cc
+++ b/modules/tests/variables_test.cc
@@ -26,7 +26,7 @@
Variables::AddValue("TEST_KEY", "TEST_VALUE");
auto value = Variables::GetValue("TEST_KEY");
ASSERT_TRUE(value.has_value());
- ASSERT_EQ("TEST_VALUE", value.value());
+ ASSERT_EQ(value.value(), "TEST_VALUE");
}
TEST(linkerconfig_variables, load_from_property) {
@@ -38,16 +38,11 @@
std::chrono::seconds(1)));
auto value = Variables::GetValue("debug.linkerconfig.test_prop_key");
ASSERT_TRUE(value.has_value());
- ASSERT_EQ("TEST_PROP_VALUE", value.value());
+ ASSERT_EQ(value.value(), "TEST_PROP_VALUE");
#endif
}
TEST(linkerconfig_variables, fallback_value) {
auto value = Variables::GetValue("INVALID_KEY");
ASSERT_FALSE(value.has_value());
-}
-
-TEST(linkerconfig_variables, empty_value) {
- Variables::AddValue("TEST_KEY", "");
- ASSERT_FALSE(Variables::GetValue("TEST_KEY").has_value());
}
\ No newline at end of file
diff --git a/modules/variables.cc b/modules/variables.cc
index 051aaba..fcc41ee 100644
--- a/modules/variables.cc
+++ b/modules/variables.cc
@@ -17,16 +17,9 @@
#include "linkerconfig/variables.h"
#include <android-base/properties.h>
-#include <regex>
-#include <sstream>
#include "linkerconfig/log.h"
-namespace {
-constexpr const char* kVariableRegex =
- "@\\{([^@\\{\\}:]+)(:([^@\\{\\}:]*))?\\}";
-}
-
namespace android {
namespace linkerconfig {
namespace modules {
@@ -53,33 +46,6 @@
void Variables::AddValue(const std::string& key, const std::string& value) {
variables_[key] = value;
}
-
-std::string Variables::ResolveVariables(const std::string& str) {
- std::string result = str;
- std::regex variable_regex(kVariableRegex);
- std::smatch sm;
-
- while (std::regex_search(result, sm, variable_regex)) {
- std::stringstream ss;
- ss << sm.prefix();
- auto resolved_value = GetValue(sm[1]);
- if (resolved_value.has_value()) {
- ss << resolved_value.value();
- } else {
- LOG(WARNING) << "Unable to find value for " << sm[1];
- bool contains_default = sm[2].length() > 0;
- if (contains_default) {
- ss << sm[3];
- } else {
- LOG(FATAL) << "There is no default value defined for " << sm[1];
- }
- }
- ss << ResolveVariables(sm.suffix());
- result = ss.str();
- }
-
- return result;
-}
} // namespace modules
} // namespace linkerconfig
} // namespace android
\ No newline at end of file