"contents/section/*.cc",
"contents/configuration/*.cc",
"contents/context/*.cc",
+ "contents/common/*.cc",
],
}
"linkerconfig_modules",
"linkerconfig_contents",
],
-}
\ No newline at end of file
+}
--- /dev/null
+/*
+ * 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();
+ Namespace* system_ns = section->GetNamespace(system_ns_name);
+ for (Namespace& ns : section->GetNamespaces()) {
+ if (&ns != system_ns) {
+ ns.GetLink(system_ns_name)
+ .AddSharedLib({"libc.so",
+ "libm.so",
+ "libdl.so",
+ "@{SANITIZER_RUNTIME_LIBRARIES}"});
+ }
+ }
+}
+
+} // namespace contents
+} // namespace linkerconfig
+} // namespace android
void Context::SetCurrentSection(SectionType section_type) {
current_section = section_type;
}
+
+std::string Context::GetSystemNamespaceName() const {
+ return IsVendorSection() ? "system" : "default";
+}
} // namespace contents
} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
+} // namespace android
--- /dev/null
+/*
+ * 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
*/
#pragma once
+#include <string>
+
namespace android {
namespace linkerconfig {
namespace contents {
void SetCurrentSection(SectionType value);
+ // Returns the namespace that covers /system/${LIB}.
+ std::string GetSystemNamespaceName() const;
+
private:
SectionType current_section;
};
} // namespace contents
} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
+} // namespace android
// /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.IsVendorSection() ? "system" : "default").AllowAllSharedLibs();
+ ns.GetLink(ctx.GetSystemNamespaceName()).AllowAllSharedLibs();
ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
using android::linkerconfig::modules::AsanPath;
using android::linkerconfig::modules::Namespace;
-namespace {
-const std::vector<std::string> kLibsFromDefault = {"libc.so",
- "libm.so",
- "libdl.so",
- "liblog.so"};
-} // namespace
-
namespace android {
namespace linkerconfig {
namespace contents {
ns.AddSearchPath("/apex/com.android.conscrypt/${LIB}", AsanPath::SAME_PATH);
ns.GetLink("art").AddSharedLib("libandroidio.so");
- ns.GetLink("default").AddSharedLib(kLibsFromDefault);
+ ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("liblog.so");
return ns;
}
using android::linkerconfig::modules::Namespace;
namespace {
-const std::vector<std::string> kLibsFromDefaultLegacy = {
- "libandroid.so",
- "libbinder_ndk.so",
- "libc.so",
- "libcgrouprc.so",
- "libdl.so",
- "liblog.so",
- "libmediametrics.so",
- "libmediandk.so",
- "libm.so",
- "libvndksupport.so",
- "libclang_rt.asan-aarch64-android.so",
- "libclang_rt.asan-arm-android.so",
- "libclang_rt.asan-i686-android.so",
- "libclang_rt.asan-x86_64-android.so",
- "libclang_rt.hwasan-aarch64-android.so"};
+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",
- "@{SANITIZER_RUNTIME_LIBRARIES}"};
+const std::vector<std::string> kLibsFromDefault = {"@{LLNDK_LIBRARIES}",
+ "libbinder_ndk.so",
+ "libmediametrics.so"};
const std::vector<std::string> kLibsFromDefaultSystem = {"libcgrouprc.so"};
} // namespace
ns.AddPermittedPath("/apex/com.android.media/${LIB}/extractors",
AsanPath::SAME_PATH);
- Link& link_to_default = ns.GetLink("default");
+ Link& system_link = ns.GetLink(ctx.GetSystemNamespaceName());
if (is_legacy) {
- link_to_default.AddSharedLib(kLibsFromDefaultLegacy);
+ system_link.AddSharedLib(kLibsFromDefaultLegacy);
} else {
- link_to_default.AddSharedLib(kLibsFromDefault);
+ system_link.AddSharedLib(kLibsFromDefault);
if (is_system_section) {
- link_to_default.AddSharedLib(kLibsFromDefaultSystem);
+ system_link.AddSharedLib(kLibsFromDefaultSystem);
}
}
ns.AddSearchPath("/apex/com.android.neuralnetworks/${LIB}",
AsanPath::SAME_PATH);
- std::string link_target = ctx.IsVendorSection() ? "system" : "default";
- ns.GetLink(link_target)
- .AddSharedLib({"libc.so",
- "libcgrouprc.so",
- "libdl.so",
+ ns.GetLink(ctx.GetSystemNamespaceName())
+ .AddSharedLib({"libcgrouprc.so",
"liblog.so",
- "libm.so",
"libnativewindow.so",
"libneuralnetworks_packageinfo.so",
"libsync.so",
using android::linkerconfig::modules::Namespace;
namespace {
-const std::vector<std::string> kLibsFromDefault = {"libc.so",
- "libcgrouprc.so",
- "libm.so",
- "libdl.so",
+const std::vector<std::string> kLibsFromDefault = {"libcgrouprc.so",
"libbinder_ndk.so",
"liblog.so",
"libvndksupport.so"};
-const std::vector<std::string> kLibsFromUnrestrictedDefault =
- {"libc.so", "libm.so", "libdl.so", "libbinder_ndk.so", "liblog.so"};
+const std::vector<std::string> kLibsFromUnrestrictedDefault = {
+ "libbinder_ndk.so",
+ "liblog.so"};
} // namespace
namespace android {
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("default").AddSharedLib(
- ctx.IsSystemSection() ? kLibsFromDefault : kLibsFromUnrestrictedDefault);
+ ns.GetLink(ctx.GetSystemNamespaceName())
+ .AddSharedLib(ctx.IsSystemSection() ? kLibsFromDefault
+ : kLibsFromUnrestrictedDefault);
return ns;
}
ns.AddPermittedPath("/system/vendor/${LIB}", AsanPath::NONE);
ns.AddPermittedPath("/data", AsanPath::SAME_PATH);
- ns.GetLink("default").AddSharedLib({"@{LLNDK_LIBRARIES}",
- "@{SANITIZER_RUNTIME_LIBRARIES}",
- "@{PRIVATE_LLNDK_LIBRARIES:}"});
+ ns.GetLink(ctx.GetSystemNamespaceName())
+ .AddSharedLib({"@{LLNDK_LIBRARIES}", "@{PRIVATE_LLNDK_LIBRARIES:}"});
ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
return ns;
ns.AddPermittedPath("/system/vendor/${LIB}", AsanPath::NONE);
ns.GetLink("rs").AddSharedLib("libRS_internal.so");
- ns.GetLink("default").AddSharedLib(
- {"@{LLNDK_LIBRARIES:}", "@{SANITIZER_RUNTIME_LIBRARIES:}"});
+ ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("@{LLNDK_LIBRARIES:}");
ns.GetLink("vndk").AddSharedLib("@{VNDK_SAMEPROCESS_LIBRARIES:}");
ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
ns.GetLink("art").AddSharedLib(
{"libdexfile_external.so",
- "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",
- "@{SANITIZER_RUNTIME_LIBRARIES}"});
+ "libicuuc.so"});
return ns;
}
"libnativeloader.so",
"libandroidicu.so",
"libpac.so",
- "@{SANITIZER_RUNTIME_LIBRARIES}",
// TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept
// for app compat.
"libicui18n.so",
// TODO(b/120786417 or b/134659294): libicuuc.so and libicui18n.so are kept
// for app compat.
"libicui18n.so",
- "libicuuc.so",
- "@{SANITIZER_RUNTIME_LIBRARIES}"};
+ "libicuuc.so"};
} // namespace
namespace android {
ns.AddPermittedPath("/vendor", AsanPath::WITH_DATA_ASAN);
ns.AddPermittedPath("/system/vendor", AsanPath::NONE);
- ns.GetLink("art").AddSharedLib("@{SANITIZER_RUNTIME_LIBRARIES}");
- ns.GetLink("system").AddSharedLib(
- {"@{LLNDK_LIBRARIES}", "@{SANITIZER_RUNTIME_LIBRARIES}"});
+ ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("@{LLNDK_LIBRARIES}");
ns.GetLink("vndk").AddSharedLib(
{"@{VNDK_SAMEPROCESS_LIBRARIES}", "@{VNDK_CORE_LIBRARIES}"});
if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
AsanPath::WITH_DATA_ASAN);
}
- ns.GetLink(is_system_section ? "default" : "system")
- .AddSharedLib({"@{LLNDK_LIBRARIES}", "@{SANITIZER_RUNTIME_LIBRARIES}"});
- ns.GetLink("art").AddSharedLib("@{SANITIZER_RUNTIME_LIBRARIES}");
+ ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib({"@{LLNDK_LIBRARIES}"});
if (is_system_section) {
ns.GetLink("sphal").AllowAllSharedLibs();
ns.AddWhitelisted("@{VNDK_USING_CORE_VARIANT_LIBRARIES}");
}
- ns.GetLink("system").AddSharedLib(
- {"@{LLNDK_LIBRARIES}", "@{SANITIZER_RUNTIME_LIBRARIES}"});
+ ns.GetLink(ctx.GetSystemNamespaceName()).AddSharedLib("@{LLNDK_LIBRARIES}");
ns.GetLink("vndk").AllowAllSharedLibs();
- ns.GetLink("art").AddSharedLib("@{SANITIZER_RUNTIME_LIBRARIES}");
ns.GetLink("neuralnetworks").AddSharedLib("libneuralnetworks.so");
return ns;
#include "linkerconfig/sectionbuilder.h"
+#include "linkerconfig/common.h"
#include "linkerconfig/namespacebuilder.h"
#include "linkerconfig/section.h"
namespaces.emplace_back(BuildResolvNamespace(ctx));
namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx));
- return Section("legacy", std::move(namespaces));
+ Section section("legacy", std::move(namespaces));
+ AddStandardSystemLinks(ctx, §ion);
+ return section;
}
} // namespace contents
} // namespace linkerconfig
#include "linkerconfig/sectionbuilder.h"
+#include "linkerconfig/common.h"
#include "linkerconfig/context.h"
#include "linkerconfig/namespacebuilder.h"
#include "linkerconfig/section.h"
namespaces.emplace_back(BuildVndkNamespace(ctx));
namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx));
- return Section("system", std::move(namespaces));
+ Section section("system", std::move(namespaces));
+ AddStandardSystemLinks(ctx, §ion);
+ return section;
}
} // namespace contents
} // namespace linkerconfig
#include "linkerconfig/sectionbuilder.h"
+#include "linkerconfig/common.h"
#include "linkerconfig/environment.h"
#include "linkerconfig/namespacebuilder.h"
#include "linkerconfig/section.h"
namespaces.emplace_back(BuildResolvNamespace(ctx));
namespaces.emplace_back(BuildNeuralNetworksNamespace(ctx));
- return Section("unrestricted", std::move(namespaces));
+ Section section("unrestricted", std::move(namespaces));
+ AddStandardSystemLinks(ctx, §ion);
+ return section;
}
} // namespace contents
} // namespace linkerconfig
#include "linkerconfig/sectionbuilder.h"
+#include "linkerconfig/common.h"
#include "linkerconfig/environment.h"
#include "linkerconfig/namespacebuilder.h"
#include "linkerconfig/section.h"
namespaces.emplace_back(BuildVndkInSystemNamespace(ctx));
}
- return Section("vendor", std::move(namespaces));
+ Section section("vendor", std::move(namespaces));
+ AddStandardSystemLinks(ctx, §ion);
+ return section;
}
} // namespace contents
} // namespace linkerconfig
std::vector<std::string> GetBinaryPaths();
std::string GetName();
- // For test usage
+ // Use for iteration only.
+ std::vector<Namespace>& GetNamespaces() {
+ return namespaces_;
+ }
+
Namespace* GetNamespace(const std::string& namespace_name);
private:
};
} // namespace modules
} // namespace linkerconfig
-} // namespace android
\ No newline at end of file
+} // namespace android