There was an issue that P vendor fails with Wifi because ubsan
libclangrt was linked to system even the library was in VNDK. This
change removes vndk libraries from sanitizer library list when linking
from vendor/product default so we can stick on partition's own VNDK
library.
Bug:
155907604
Test: Tested with cuttlefish
Change-Id: I7c23c6ba5f263a716b44778c9441dde68943259b
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) {
+ const std::string system_ns_name = ctx.GetSystemNamespaceName();
+ const bool is_section_vndk_enabled = ctx.IsSectionVndkEnabled();
+ section->ForEachNamespaces([&](Namespace& ns) {
if (ns.GetName() != system_ns_name) {
- ns.GetLink(system_ns_name)
- .AddSharedLib(Var("STUB_LIBRARIES"),
- Var("SANITIZER_RUNTIME_LIBRARIES"));
+ if (!is_section_vndk_enabled || ns.GetName() != "default") {
+ ns.GetLink(system_ns_name)
+ .AddSharedLib(Var("STUB_LIBRARIES"),
+ Var("SANITIZER_RUNTIME_LIBRARIES"));
+ }
}
});
}
#include <android-base/strings.h>
+#include "linkerconfig/environment.h"
#include "linkerconfig/log.h"
#include "linkerconfig/namespacebuilder.h"
#include "linkerconfig/variables.h"
return default_value;
}
+bool Context::IsSectionVndkEnabled() const {
+ if (!IsVndkAvailable() || android::linkerconfig::modules::IsVndkLiteDevice()) {
+ return false;
+ }
+ if (IsVendorSection()) {
+ return true;
+ }
+ if (IsProductSection() &&
+ android::linkerconfig::modules::IsProductVndkVersionDefined()) {
+ return true;
+ }
+
+ return false;
+}
+
} // namespace contents
} // namespace linkerconfig
} // namespace android
void RegisterApexNamespaceBuilder(const std::string& name,
ApexNamespaceBuilder builder);
+ bool IsSectionVndkEnabled() const;
+
private:
std::map<std::string, ApexNamespaceBuilder> builders_;
ns.AddPermittedPath(Var("PRODUCT", "product"), AsanPath::WITH_DATA_ASAN);
ns.GetLink(ctx.GetSystemNamespaceName())
- .AddSharedLib(Var("LLNDK_LIBRARIES_PRODUCT"));
+ .AddSharedLib(
+ {Var("LLNDK_LIBRARIES_PRODUCT"), Var("SANITIZER_DEFAULT_PRODUCT")});
ns.GetLink("vndk").AddSharedLib({Var("VNDK_SAMEPROCESS_LIBRARIES_PRODUCT"),
Var("VNDK_CORE_LIBRARIES_PRODUCT")});
if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
ns.AddRequires(kVndkLiteVendorRequires);
} else {
ns.GetLink(ctx.GetSystemNamespaceName())
- .AddSharedLib(Var("LLNDK_LIBRARIES_VENDOR"));
+ .AddSharedLib(
+ {Var("LLNDK_LIBRARIES_VENDOR"), Var("SANITIZER_DEFAULT_VENDOR")});
ns.GetLink("vndk").AddSharedLib({Var("VNDK_SAMEPROCESS_LIBRARIES_VENDOR"),
Var("VNDK_CORE_LIBRARIES_VENDOR")});
if (android::linkerconfig::modules::IsVndkInSystemNamespace()) {
Variables::AddValue("VNDK_SAMEPROCESS_LIBRARIES_" + partition,
"vndk_sameprocess_libraries");
Variables::AddValue("VNDK_CORE_LIBRARIES_" + partition, "vndk_core_libraries");
+ Variables::AddValue("SANITIZER_DEFAULT_" + partition,
+ "sanitizer_default_libraries");
}
inline void MockVariables(std::string vndk_ver = "Q") {
"VNDK_USING_CORE_VARIANT_LIBRARIES", "");
android::linkerconfig::modules::Variables::AddValue("STUB_LIBRARIES",
"stub_libraries");
+ android::linkerconfig::modules::Variables::AddValue(
+ "SANITIZER_DEFAULT_VENDOR", "sanitizer_default_libraries");
+ android::linkerconfig::modules::Variables::AddValue(
+ "SANITIZER_DEFAULT_PRODUCT", "sanitizer_default_libraries");
}
inline void MockVndkVersion(std::string vndk_version) {
#include <android-base/result.h>
#include <android-base/strings.h>
+
#include <climits>
#include <cstdlib>
#include <cstring>
vndk_path + "/etc/vndkcore.libraries." + vndk_version + ".txt";
const std::string vndkprivate_libraries_path =
vndk_path + "/etc/vndkprivate.libraries." + vndk_version + ".txt";
+ const std::string sanitizer_library_path =
+ root + "/system/etc/sanitizer.libraries.txt";
Variables::AddValue("LLNDK_LIBRARIES_" + partition,
GetPublicLibrariesString(llndk_libraries_path,
GetPublicLibrariesString(vndkcore_libraries_path,
vndkprivate_libraries_path));
+ Variables::AddValue("SANITIZER_DEFAULT_" + partition,
+ GetPublicLibrariesString(sanitizer_library_path,
+ vndkcore_libraries_path));
+
if (partition == "VENDOR") {
auto vndkcorevariant_library_path =
root + "/system/etc/vndkcorevariant.libraries.txt";