From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id CF6C7385801A for ; Sun, 1 Aug 2021 20:15:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CF6C7385801A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by sf.home (Postfix, from userid 1000) id 2BC804D77A40; Sun, 1 Aug 2021 21:15:38 +0100 (BST) From: Sergei Trofimovich To: debugedit@sourceware.org Cc: Sergei Trofimovich Subject: [PATCH] use $READELF, not readelf Date: Sun, 1 Aug 2021 21:15:35 +0100 Message-Id: <20210801201535.3170290-1-slyfox@gentoo.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: debugedit@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: debugedit development mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Aug 2021 20:15:46 -0000 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 --- 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