Revert "Load /dev/linker/ld.config.txt by default"
This reverts commit 61a97e95052a4ff22c7d2315f00cb3f0a5bce99e.
Reason for revert: Breaks ART run-tests (b/143458513).
Test: Run ART tests on device in a chroot environment
Bug: 143458513
Bug: 139638519
Change-Id: Ib047a24d6e82e38ebdaafeab294b8be44b74bd9c
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 3c30e73..dec575b 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -92,6 +92,7 @@
static const char* const kLdConfigArchFilePath = "/system/etc/ld.config." ABI_STRING ".txt";
static const char* const kLdConfigFilePath = "/system/etc/ld.config.txt";
+static const char* const kLdConfigVndkLiteFilePath = "/system/etc/ld.config.vndk_lite.txt";
static const char* const kLdGeneratedConfigFilePath = "/dev/linkerconfig/ld.config.txt";
@@ -4053,13 +4054,30 @@
}
static std::string get_ld_config_file_vndk_path() {
- if (!file_exists(kLdGeneratedConfigFilePath)) {
- DL_WARN("Warning: failed to find generated linker configuration from \"%s\"",
- kLdGeneratedConfigFilePath);
- return "";
+ if (android::base::GetBoolProperty("ro.vndk.lite", false)) {
+ return kLdConfigVndkLiteFilePath;
}
- return kLdGeneratedConfigFilePath;
+ // Use generated linker config if flag is set
+ // TODO(b/138920271) Do not check property once it is confirmed as stable
+ // TODO(b/139638519) This file should also cover legacy or vndk-lite config
+ if (android::base::GetProperty("ro.vndk.version", "") != "" &&
+ android::base::GetBoolProperty("sys.linker.use_generated_config", true)) {
+ if (file_exists(kLdGeneratedConfigFilePath)) {
+ return kLdGeneratedConfigFilePath;
+ } else {
+ DL_WARN("Warning: failed to find generated linker configuration from \"%s\"",
+ kLdGeneratedConfigFilePath);
+ }
+ }
+
+ std::string ld_config_file_vndk = kLdConfigFilePath;
+ size_t insert_pos = ld_config_file_vndk.find_last_of('.');
+ if (insert_pos == std::string::npos) {
+ insert_pos = ld_config_file_vndk.length();
+ }
+ ld_config_file_vndk.insert(insert_pos, Config::get_vndk_version_string('.'));
+ return ld_config_file_vndk;
}
static std::string get_ld_config_file_path(const char* executable_path) {
@@ -4087,7 +4105,7 @@
}
path = get_ld_config_file_vndk_path();
- if (!path.empty()) {
+ if (file_exists(path.c_str())) {
return path;
}