commit: 86b4553f5c38bc96b876ce625c7990e559f40885
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Tue Jun 3 20:12:15 2025 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jun 3 20:49:53 2025 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=86b4553f
estrip: reliably detect missing tools
Presently, estrip performs a PATH search for tools such as strip(1) and
objcopy(1), yet only in the case of their CHOST-prefixed names. Should
this initial PATH search fail, the tool will be presumed to exist by its
non-prefixed name, without going so far as to check whether it actually
does. Consider the following scenario.
1) the "type -P x86_64-pc-linux-gnu-dwz" command exits with 1
2) the tool is thus assumed to be available as "dwz" (without checking)
Though I recently reworked the code, it was not I that introduced this
bug. Rather, I inadvertently preserved it. However, now that I have
identified it, I can certainly fix it. Do so by assigning nothing but
the captured output of the type builtin as values of the 'path_of' map,
irrespective of the name being searched for.
Fixes: a67dc215adb52392505d03870c236e828dca3625
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
Signed-off-by: Sam James <sam <AT> gentoo.org>
bin/estrip | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/bin/estrip b/bin/estrip
index 1f4cfceb27..086c717a44 100755
--- a/bin/estrip
+++ b/bin/estrip
@@ -159,11 +159,10 @@ fi
# Look up the tools we might be using
declare -A path_of
-for bin in strip objcopy readelf ranlib; do
- if [[ $CHOST ]] && path_of[$bin]=$(type -P -- "${CHOST}-${bin}"
2>/dev/null); then
- continue
- fi
- path_of[$bin]=$bin
+for bin in {"${CHOST}-",}{'strip','objcopy','readelf','ranlib'}; do
+ if [[ ! ${path_of[$bin]} ]]; then
+ path_of[$bin]=$(type -P -- "${bin}" 2>/dev/null)
+ fi
done
# Declare a map to keep track of whether warnings in certain categories have