From 33de2737d96946c2e8ee5e07218b49d782a9ca65 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 25 Apr 2024 16:44:48 +0000 Subject: get_executable_info: minor clarification. Change the comment to explain _why_ we're resolving the path, get rid of unnecessarily explicit strlen() calls, and make it clearer that result.path is unconditionally initialized; it's just the specific content that varies. Change-Id: Iffbd5efc2eafd56e3efa3c0aaf7c191e6bb66a04 --- linker/linker_main.cpp | 10 +++------- 1 file 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(getauxval(AT_PHDR)); result.phdr_count = getauxval(AT_PHNUM); -- cgit v1.2.3