Use generated linker config for APEX binaries
LinkerConfig will start to generate linker configuration for APEX
binaries. Linker should check if this generated file exists first, and
use it if exists and otherwise use ld.config.txt under APEX etc.
Bug: 147987608
Test: m -j passed
Test: Tested with adbd and SWCodec from Cuttlefish and Crosshatch
Change-Id: I5a0c28ee1a427adface3e67c8af062e1b2ef6197
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 8de82d5..f5cf5ec 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -3454,6 +3454,12 @@
static std::string get_ld_config_file_apex_path(const char* executable_path) {
std::vector<std::string> paths = android::base::Split(executable_path, "/");
if (paths.size() >= 5 && paths[1] == "apex" && paths[3] == "bin") {
+ // Check auto-generated ld.config.txt first
+ std::string generated_apex_config = "/linkerconfig/" + paths[2] + "/ld.config.txt";
+ if (file_exists(generated_apex_config.c_str())) {
+ return generated_apex_config;
+ }
+
return std::string("/apex/") + paths[2] + "/etc/ld.config.txt";
}
return "";