Add linker config variable: VNDK_APEX_VER

With VNDK APEX, the path for VNDK libs has been changed
from /system/lib/vndk-VER to /apex/com.android.vndk.vVER/lib

In most cases, vndk version can be substituted when generating
ld.config.txt by linkerconfig.

But, ld.config.txt files in APEX packages still rely on runtime substitution.
Specifically, com.android.media.swcodec is using VNDK_VER variable.
Moreover, it cannot migrate to a new location since it should run on
older version of system due to APEX requirements.

For backward compatibility, instead of changing the value of old
variable, a new variable is added.

- VNDK_VER : "-" prefixed vndk version, used for older path
            (e.g. /system/lib/vndk-sp-29)
- VNDK_APEX_VER : "v" prefixed vndk versions.
            (e.g. /apex/com.android.vndk.v29/lib)

Test: add a vendor binary to /apex/com.android.media.swcodec/bin
      which opens /system/lib/vndk-sp{VNDK_VER}/hw/android.hidl.memory@1.0-impl.so
      via android_load_sphal_library()
Bug: 142912195

Change-Id: I3dfb3c1068cff00d5b63e92d51da6c4af00d264e
diff --git a/linker/linker_config.cpp b/linker/linker_config.cpp
index 46c91a3..85ea8d1 100644
--- a/linker/linker_config.cpp
+++ b/linker/linker_config.cpp
@@ -408,8 +408,10 @@
       params.push_back({ "SDK_VER", buf });
     }
 
-    static std::string vndk = Config::get_vndk_version_string('-');
-    params.push_back({ "VNDK_VER", vndk });
+    static std::string vndk_ver = Config::get_vndk_version_string('-');
+    params.push_back({ "VNDK_VER", vndk_ver });
+    static std::string vndk_apex_ver = Config::get_vndk_version_string('v');
+    params.push_back({ "VNDK_APEX_VER", vndk_apex_ver });
 
     for (auto& path : paths) {
       format_string(&path, params);