public inbox for debugedit@sourceware.org
 help / color / mirror / Atom feed
From: Sergei Trofimovich <slyfox@gentoo.org>
To: debugedit@sourceware.org
Cc: Sergei Trofimovich <slyfox@gentoo.org>
Subject: [PATCH] use $READELF, not readelf
Date: Sun,  1 Aug 2021 21:15:35 +0100	[thread overview]
Message-ID: <20210801201535.3170290-1-slyfox@gentoo.org> (raw)

Allow user to specify own readelf. Use detected readelf,
not 'readelf'.

Noticed as a set of test failures on system with only
$host-prefixed tools:

  debugedit/tests/testsuite.dir/at-groups/4/test-source:
    line 40: readelf: command not found

	* configure.ac: Add READELF user override.
	* scripts/find-debuginfo.in: Use @READELF@ instead of 'readelf'.
	* tests/atlocal.in: Populate READELF variable detected by configure.
	* tests/debugedit.at: Use $READELF instad of 'readelf' in tests.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
---
 configure.ac              |  1 +
 scripts/find-debuginfo.in |  2 +-
 tests/atlocal.in          |  1 +
 tests/debugedit.at        | 54 +++++++++++++++++++--------------------
 4 files changed, 30 insertions(+), 28 deletions(-)

diff --git a/configure.ac b/configure.ac
index 85f2c4f..e5c9230 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,6 +44,7 @@ AC_PROG_SED
 AC_PROG_CC_C99
 AC_PROG_LN_S
 AC_CHECK_TOOL([LD], [ld])
+AC_CHECK_TOOL([READELF], [readelf])
 AM_MISSING_PROG(HELP2MAN, help2man)
 
 # Only really an issue on 32bit platforms. Makes sure we'll get large off_t.
diff --git a/scripts/find-debuginfo.in b/scripts/find-debuginfo.in
index 8b9ce77..34f62ed 100755
--- a/scripts/find-debuginfo.in
+++ b/scripts/find-debuginfo.in
@@ -338,7 +338,7 @@ add_minidebug()
   # symbol and NOBITS sections so cannot use --keep-only because that is
   # too aggressive. Field $2 is the section name, $3 is the section type
   # and $8 are the section flags.
-  local remove_sections=`readelf -W -S "$debuginfo" \
+  local remove_sections=`@REAADELF@ -W -S "$debuginfo" \
 	| awk '{ if (index($2,".debug_") != 1 \
 		     && ($3 == "PROGBITS" || $3 == "NOTE" || $3 == "NOBITS") \
 		     && index($8,"A") == 0) \
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 0eec351..8399f8d 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -9,6 +9,7 @@ CC="@CC@"
 CFLAGS=""
 LD="@LD@"
 LDFLAGS=""
+READELF="@READELF@"
 
 GDWARF_5_FLAG=@GDWARF_5_FLAG@
 GZ_NONE_FLAG=@GZ_NONE_FLAG@
diff --git a/tests/debugedit.at b/tests/debugedit.at
index 608b1d0..0311d26 100644
--- a/tests/debugedit.at
+++ b/tests/debugedit.at
@@ -93,7 +93,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
+$READELF -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
         | grep ^$(pwd) | sort \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -108,7 +108,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
+$READELF -p.debug_str foo.o subdir_bar/bar.o baz.o | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -125,7 +125,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
+$READELF -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
         | cut -c13- \
         | grep ^$(pwd) | sort | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
@@ -141,7 +141,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
+$READELF -p.debug_str -p.debug_line_str foo.o subdir_bar/bar.o baz.o \
         | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
@@ -160,7 +160,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 # (and replace that textually with /foo/bar/baz)
 # Note that partially linked files, might have multiple duplicate
 # strings, but debugedit will merge them. So use sort -u.
-readelf -p.debug_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str ./foobarbaz.part.o | cut -c13- \
         | grep ^$(pwd) | sort -u \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -173,7 +173,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf -p.debug_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str ./foobarbaz.part.o | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -192,7 +192,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 # (and replace that textually with /foo/bar/baz)
 # Note that partially linked files, might have multiple duplicate
 # strings, but debugedit will merge them. So use sort -u.
-readelf -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
         | grep ^$(pwd) | sort -u | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -205,7 +205,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str ./foobarbaz.part.o | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
 
@@ -221,7 +221,7 @@ DEBUGEDIT_SETUP([-gdwarf-4])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str foobarbaz.exe | cut -c13- \
         | grep ^$(pwd) | sort \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -235,7 +235,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf -p.debug_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str foobarbaz.exe | cut -c13- \
         | grep ^/foo/bar/baz | sort
 ]],[0],[expout])
 
@@ -252,7 +252,7 @@ DEBUGEDIT_SETUP([-gdwarf-5])
 
 # Capture strings that start with the testdir (pwd) directory path
 # (and replace that textually with /foo/bar/baz)
-readelf -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
         | grep ^$(pwd) | sort | uniq \
         | sed -e "s@$(pwd)@/foo/bar/baz@" > expout
 
@@ -266,7 +266,7 @@ fi
 # Check the replaced strings are all there.
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
+$READELF -p.debug_str -p.debug_line_str foobarbaz.exe | cut -c13- \
         | grep ^/foo/bar/baz | sort | uniq
 ]],[0],[expout],[ignore])
 
@@ -305,7 +305,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=info foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=info foo.o subdir_bar/bar.o baz.o \
         | grep -E 'DW_AT_(name|comp_dir)' \
         | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
 ]],[0],[expout])
@@ -328,7 +328,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.part.o \
+$READELF --debug-dump=info ./foobarbaz.part.o \
         | grep -E 'DW_AT_(name|comp_dir)' \
         | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
 ]],[0],[expout])
@@ -351,7 +351,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.exe | grep -E 'DW_AT_(name|comp_dir)' \
+$READELF --debug-dump=info ./foobarbaz.exe | grep -E 'DW_AT_(name|comp_dir)' \
         | rev | cut -d: -f1 | rev | cut -c2- | grep ^/foo/bar/baz | sort -u
 ]],[0],[expout])
 
@@ -385,7 +385,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
 for i in ./foo.o ./subdir_bar/bar.o ./baz.o;do \
-  readelf --debug-dump=info $i \
+  $READELF --debug-dump=info $i \
           | awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
           | sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
           | sort;
@@ -415,7 +415,7 @@ stz
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.part.o \
+$READELF --debug-dump=info ./foobarbaz.part.o \
         | awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
         | sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
         | sort
@@ -444,7 +444,7 @@ stz
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=info ./foobarbaz.exe \
+$READELF --debug-dump=info ./foobarbaz.exe \
         | awk '/Abbrev Number:.*DW_TAG_type_unit/{p=1}{if(p)print}/^$/{p=0}' \
         | sed -n 's/^.*> *DW_AT_name *:.* \(stringp[^ ]*\|st.\)$/\1/p' \
         | sort
@@ -474,7 +474,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=line foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
         | grep -A3 "The Directory Table" | grep "^  [123]" \
 	| grep /foo/ | cut -c5- | sort
 ]],[0],[expout])
@@ -499,7 +499,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=line foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=line foo.o subdir_bar/bar.o baz.o \
         | grep -A5 "The Directory Table" | grep "^  [123]" \
 	| cut -f2- -d/ | grep ^foo/ | sort
 ]],[0],[expout])
@@ -521,7 +521,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.part.o \
+$READELF --debug-dump=line ./foobarbaz.part.o \
         | grep -A3 "The Directory Table" | grep "^  [123]" \
 	| grep /foo/ | cut -c5- | sort
 ]],[0],[expout])
@@ -544,7 +544,7 @@ foo/bar/baz/subdir_headers
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.part.o \
+$READELF --debug-dump=line ./foobarbaz.part.o \
         | grep -A5 "The Directory Table" | grep "^  [123]" \
 	| cut -f2- -d/ | grep ^foo/ | sort
 ]],[0],[expout])
@@ -566,7 +566,7 @@ AT_DATA([expout],
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.exe \
+$READELF --debug-dump=line ./foobarbaz.exe \
         | grep -A3 "The Directory Table" | grep "^  [123]" \
 	| grep /foo/ | cut -c5- | sort
 ]],[0],[expout])
@@ -589,7 +589,7 @@ foo/bar/baz/subdir_headers
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=line ./foobarbaz.exe \
+$READELF --debug-dump=line ./foobarbaz.exe \
         | grep -A5 "The Directory Table" | grep "^  [123]" \
 	| cut -f2- -d/ | grep ^foo/ | sort
 ]],[0],[expout])
@@ -615,7 +615,7 @@ AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foo.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./subdir_bar/bar.o]])
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./baz.o]])
 AT_CHECK([[
-readelf --debug-dump=macro foo.o subdir_bar/bar.o baz.o \
+$READELF --debug-dump=macro foo.o subdir_bar/bar.o baz.o \
         | grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
 ]],[0],[expout])
 
@@ -638,7 +638,7 @@ NUMBER 42
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.part.o]])
 AT_CHECK([[
-readelf --debug-dump=macro ./foobarbaz.part.o \
+$READELF --debug-dump=macro ./foobarbaz.part.o \
         | grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
 ]],[0],[expout])
 
@@ -661,7 +661,7 @@ NUMBER 42
 
 AT_CHECK([[debugedit -b $(pwd) -d /foo/bar/baz ./foobarbaz.exe]])
 AT_CHECK([[
-readelf --debug-dump=macro ./foobarbaz.exe \
+$READELF --debug-dump=macro ./foobarbaz.exe \
         | grep NUMBER | rev | cut -d: -f1 | rev | cut -c2-
 ]],[0],[expout])
 
-- 
2.32.0


             reply	other threads:[~2021-08-01 20:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-01 20:15 Sergei Trofimovich [this message]
2021-08-01 21:30 ` Mark Wielaard
2021-08-01 23:47   ` Sergei Trofimovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210801201535.3170290-1-slyfox@gentoo.org \
    --to=slyfox@gentoo.org \
    --cc=debugedit@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).