Set search path to ro.vndk.version property
The permitted and search paths should be changed according to VNDK
version for VNDK snapshot. So, {VNDK_VER} value is added in ld.config.txt
file and this value is set through the linker.
If ro.vndk.version is not set, search paths are vndk and vndk-sp as
before.
Bug: 66074376
Test: build & run
Change-Id: I266b66fe1bc95d8925053ef497db11ac0a57c082
diff --git a/linker/linker_config.cpp b/linker/linker_config.cpp
index e036c05..f7d2c53 100644
--- a/linker/linker_config.cpp
+++ b/linker/linker_config.cpp
@@ -43,6 +43,9 @@
#include <string>
#include <unordered_map>
+#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+#include <sys/_system_properties.h>
+
class ConfigParser {
public:
enum {
@@ -275,6 +278,15 @@
return true;
}
+static std::string getVndkVersionString() {
+ char vndk_version_str[1 + PROP_VALUE_MAX] = {};
+ __system_property_get("ro.vndk.version", vndk_version_str + 1);
+ if (strlen(vndk_version_str + 1) != 0 && strcmp(vndk_version_str + 1, "current") != 0) {
+ vndk_version_str[0] = '-';
+ }
+ return vndk_version_str;
+}
+
static Config g_config;
static constexpr const char* kDefaultConfigName = "default";
@@ -334,6 +346,9 @@
params.push_back({ "SDK_VER", buf });
}
+ static std::string vndk = getVndkVersionString();
+ params.push_back({ "VNDK_VER", vndk });
+
for (auto&& path : paths) {
format_string(&path, params);
}