Use ld.config.$VER.txt when current VNDK version is $VER

When ro.vndk.version is set to a specific version, not "current",
use ld.config.$VER.txt as a linker namespace configuration file,
where $VER is the VNDK version set by ro.vndk.version.

Because ro.vndk.version is set by the vendor partition, the
configuration file will be automatically selected by the VNDK version
of vendor patition.

If ro.vndk.version is current or not set, ld.config.txt will be used
as before.

Bug: 69531793
Test: Build for a Pixel2 device.
  In the out/target/product/<device> directory,
    rename system/etc/ld.config.txt to system/etc/ld.config.27.1.0.txt
    rename system/lib[64]/vndk to system/lib[64]/vndk-27.1.0
    copy system/lib[64]/vndk-sp to system/lib[64]/vndk-sp-27.1.0
    set ro.vndk.version to 27.1.0 in vendor/default.prop
  Build system and vendor images with "make snod" and "make vnod".
  Disble vbmeta using avbtool.
  Flash a device and check boot.

Change-Id: Ic55bb0a741d434e5fa93e109be15df9d9de3f105
diff --git a/linker/linker_config.cpp b/linker/linker_config.cpp
index f7d2c53..1af5da8 100644
--- a/linker/linker_config.cpp
+++ b/linker/linker_config.cpp
@@ -33,6 +33,7 @@
 #include "linker_utils.h"
 
 #include <android-base/file.h>
+#include <android-base/properties.h>
 #include <android-base/scopeguard.h>
 #include <android-base/strings.h>
 
@@ -278,15 +279,6 @@
   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";
@@ -346,7 +338,7 @@
       params.push_back({ "SDK_VER", buf });
     }
 
-    static std::string vndk = getVndkVersionString();
+    static std::string vndk = Config::get_vndk_version_string('-');
     params.push_back({ "VNDK_VER", vndk });
 
     for (auto&& path : paths) {
@@ -503,6 +495,15 @@
   return true;
 }
 
+std::string Config::get_vndk_version_string(const char delimiter) {
+  std::string version = android::base::GetProperty("ro.vndk.version", "");
+  if (version != "" && version != "current") {
+    //add the delimiter char in front of the string and return it.
+    return version.insert(0, 1, delimiter);
+  }
+  return "";
+}
+
 NamespaceConfig* Config::create_namespace_config(const std::string& name) {
   namespace_configs_.push_back(std::unique_ptr<NamespaceConfig>(new NamespaceConfig(name)));
   NamespaceConfig* ns_config_ptr = namespace_configs_.back().get();