aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2024-04-26 15:04:19 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-26 15:04:19 +0000
commitf789ddab1e1bdd3fdff6737b1fd0151ddff0ca00 (patch)
treedf057686bc1c5bd3a7485b4a5534b532e40360ef
parentfc306b951b92911608d8234f499c42ffb106149a (diff)
parent33de2737d96946c2e8ee5e07218b49d782a9ca65 (diff)
downloadbionic-f789ddab1e1bdd3fdff6737b1fd0151ddff0ca00.tar.gz
Merge "get_executable_info: minor clarification." into main
-rw-r--r--linker/linker_main.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index f966e04db..089ecebf9 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -221,14 +221,10 @@ static ExecutableInfo get_executable_info(const char* arg_path) {
exe_path = arg_path;
}
- // Path might be a symlink
+ // Path might be a symlink; we need the target so that we get the right
+ // linker configuration later.
char sym_path[PATH_MAX];
- auto ret = realpath(exe_path, sym_path);
- if (ret != nullptr) {
- result.path = std::string(sym_path, strlen(sym_path));
- } else {
- result.path = std::string(exe_path, strlen(exe_path));
- }
+ result.path = std::string(realpath(exe_path, sym_path) != nullptr ? sym_path : exe_path);
result.phdr = reinterpret_cast<const ElfW(Phdr)*>(getauxval(AT_PHDR));
result.phdr_count = getauxval(AT_PHNUM);