]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
egrep in binutils
authorAlan Modra <amodra@gmail.com>
Wed, 28 Sep 2022 04:07:31 +0000 (13:37 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 28 Sep 2022 04:07:31 +0000 (13:37 +0930)
Apparently some distros have a nagging egrep that helpfully tells you
egrep is deprecated and to use "grep -E".  The nag message causes a ld
testsuite failure.  What's more the advice isn't that good.  The "-E"
flag may not be available with older versions of grep.

This patch fixes bare invocation of egrep within binutils, replacing
it with the autoconf $EGREP or with grep.

config/
* lib-ld.m4 (AC_LIB_PROG_LD_GNU): Require AC_PROG_EGREP and
invoke $EGREP.
(AC_LIB_PROG_LD): Likewise.
binutils/
* configure: Regenerate.
* embedspu.sh: Replace egrep with grep.
gold/
* testsuite/Makefile.am (flagstest_compress_debug_sections.check):
Replace egrep with grep.
* testsuite/Makefile.in: Regenerate.
* testsuite/bnd_ifunc_1.sh: Replace egrep with $EGREP.
* testsuite/bnd_ifunc_2.sh: Likewise.
* testsuite/bnd_plt_1.sh: Likewise.
* testsuite/discard_locals_test.sh: Likewise.
* testsuite/gnu_property_test.sh: Likewise.
* testsuite/no_version_test.sh: Likewise.
* testsuite/pr18689.sh: Likewise.
* testsuite/pr26936.sh: Likewise.
* testsuite/retain.sh: Likewise.
* testsuite/split_i386.sh: Likewise.
* testsuite/split_s390.sh: Likewise.
* testsuite/split_x32.sh: Likewise.
* testsuite/split_x86_64.sh: Likewise.
* testsuite/ver_test_pr16504.sh: Likewise.
intl/
* configure: Regenerate.
ld/
* testsuite/ld-elfvers/vers.exp (test_ar): Replace egrep with grep.

21 files changed:
binutils/configure
binutils/embedspu.sh
config/lib-ld.m4
gold/testsuite/Makefile.am
gold/testsuite/Makefile.in
gold/testsuite/bnd_ifunc_1.sh
gold/testsuite/bnd_ifunc_2.sh
gold/testsuite/bnd_plt_1.sh
gold/testsuite/discard_locals_test.sh
gold/testsuite/gnu_property_test.sh
gold/testsuite/no_version_test.sh
gold/testsuite/pr18689.sh
gold/testsuite/pr26936.sh
gold/testsuite/retain.sh
gold/testsuite/split_i386.sh
gold/testsuite/split_s390.sh
gold/testsuite/split_x32.sh
gold/testsuite/split_x86_64.sh
gold/testsuite/ver_test_pr16504.sh
intl/configure
ld/testsuite/ld-elfvers/vers.exp

index 0d6bde7b4a5db08387f7c64c61eb7e59eed49eac..7a45037a82fe66f612422b7d87eb33be1e223e3d 100755 (executable)
@@ -13851,7 +13851,7 @@ else
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
        test "$with_gnu_ld" != no && break
       else
        test "$with_gnu_ld" != yes && break
@@ -13879,7 +13879,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
index 42fcd0633713f91722f84422347340b1ae8d0853..361206f7d88ba75800c97b8b4c0a9c79ef2bf8ce 100644 (file)
@@ -108,9 +108,11 @@ main ()
   READELF="$prog"
 
   # Sanity check the input file
-  if ! ${READELF} -h ${INFILE} | grep 'Class:.*ELF32' >/dev/null 2>/dev/null \
-     || ! ${READELF} -h ${INFILE} | grep 'Type:.*EXEC' >/dev/null 2>/dev/null \
-     || ! ${READELF} -h ${INFILE} | egrep 'Machine:.*(SPU|17)' >/dev/null 2>/dev/null
+  match="Class:.*ELF32
+Type:.*EXEC
+Machine:.*SPU
+Machine:.*17"
+  if test `${READELF} -h ${INFILE} | grep "${match}" | wc -l` != 3
   then
     echo "${INFILE}: Does not appear to be an SPU executable"
     exit 1
index 11d0ce773427a291e20709295a87ac98df60f0ce..73cf9571b5780a999b3cbc0b8ea361d1d38ea347 100644 (file)
@@ -12,9 +12,10 @@ dnl with libtool.m4.
 
 dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
 AC_DEFUN([AC_LIB_PROG_LD_GNU],
-[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
@@ -29,6 +30,7 @@ AC_DEFUN([AC_LIB_PROG_LD],
 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
 AC_REQUIRE([AC_PROG_CC])dnl
 AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_EGREP])dnl
 # Prepare PATH_SEPARATOR.
 # The user is always right.
 if test "${PATH_SEPARATOR+set}" != set; then
@@ -88,7 +90,7 @@ AC_CACHE_VAL(acl_cv_path_LD,
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
        test "$with_gnu_ld" != no && break
       else
        test "$with_gnu_ld" != yes && break
index b15000ee7f3a4b959bc5d648c0502c7d27f848aa..843fd0d197ca2d64f3e6492b0f10a7538dd3b0db 100644 (file)
@@ -1702,7 +1702,7 @@ flagstest_compress_debug_sections.stdout: flagstest_compress_debug_sections
 
 # Check there are compressed DWARF .debug_* sections.
 flagstest_compress_debug_sections.check: flagstest_compress_debug_sections
-       $(TEST_READELF) -SW $< | egrep ".debug_.* C *" > $@.tmp
+       $(TEST_READELF) -SW $< | grep "\.debug_.* C" > $@.tmp
        mv -f $@.tmp $@
 
 # Compare DWARF debug info.
index 78bb0cc7a264f834ec8c59b93eaa516e4cbfac20..21804df65736e73de7bcf0391f62aa7165b7bb28 100644 (file)
@@ -8732,7 +8732,7 @@ uninstall-am:
 
 # Check there are compressed DWARF .debug_* sections.
 @GCC_TRUE@@NATIVE_LINKER_TRUE@flagstest_compress_debug_sections.check: flagstest_compress_debug_sections
-@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SW $< | egrep ".debug_.* C *" > $@.tmp
+@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SW $< | grep "\.debug_.* C" > $@.tmp
 @GCC_TRUE@@NATIVE_LINKER_TRUE@ mv -f $@.tmp $@
 
 # Compare DWARF debug info.
index 64245bee964b9a5ee167438fc4eb892f8428c56c..b70f2f7d7d90bc7f07f97c2693bcc219fa75b844 100755 (executable)
 
 match()
 {
-  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+  if ! $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "could not find '$1' in $2"
     exit 1
   fi
 }
 
 match '[0-9a-f]*:.*bnd jmp \*0x[0-9a-f]*\(%rip\) *# [0-9a-f]* <_GLOBAL_OFFSET_TABLE_\+0x18>' bnd_ifunc_1.stdout
-APLT_ADDR=$(egrep '[0-9a-f]*:.*bnd jmp \*0x[0-9a-f]*\(%rip\) *# [0-9a-f]* <_GLOBAL_OFFSET_TABLE_\+0x18>' bnd_ifunc_1.stdout |
+APLT_ADDR=$($EGREP '[0-9a-f]*:.*bnd jmp \*0x[0-9a-f]*\(%rip\) *# [0-9a-f]* <_GLOBAL_OFFSET_TABLE_\+0x18>' bnd_ifunc_1.stdout |
   sed -e 's/ *\([0-9a-f]*\):.*/\1/')
 match "bnd call $APLT_ADDR" bnd_ifunc_1.stdout
index d9f0e6dd46308af9da019d94aa85cab0309346b3..b660553a2b9ef691953dc0267ac988072541bede 100755 (executable)
@@ -24,7 +24,7 @@
 
 match()
 {
-  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+  if ! $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "could not find '$1' in $2"
     exit 1
   fi
index 5fde21edcd85e7b05002a6da3ea54a97e714a9d7..b34890560397e909b8a27daaff57a94799a6b7f5 100755 (executable)
@@ -24,7 +24,7 @@
 
 match()
 {
-  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+  if ! $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "could not find '$1' in $2"
     exit 1
   fi
index d89e3bd4d3e0ec3c271563563864f13060b35c98..2a0ab03689701e5f681872b89cc9e445420d9786 100755 (executable)
@@ -32,7 +32,7 @@ check_discarded()
     file=$1
     sym=$2
 
-    found=`egrep $sym $file`
+    found=`$EGREP $sym $file`
     if test -n "$found"; then
        echo "These local symbols are not discarded in $file:"
        echo "$found"
@@ -45,7 +45,7 @@ check_non_discarded()
     file=$1
     sym=$2
 
-    found=`egrep $sym $file`
+    found=`$EGREP $sym $file`
     if test -z "$found"; then
        echo "This local symbol is discarded in $file:"
        echo "$2"
index 1a3cae27eb66628c2d5788966e11ec81692b5096..406ad205dbea34253ff1953bb0397a76fcf4f6b4 100755 (executable)
@@ -55,16 +55,16 @@ check_count()
 
 check_alignment ()
 {
-    if egrep -q "Class:[ \t]+ELF64" "$1"
+    if $EGREP -q "Class:[ \t]+ELF64" "$1"
     then
        align=8
     else
        align=4
     fi
-    if ! egrep -q ".note.gnu.property[ \t]+NOTE.*$align$" "$1"
+    if ! $EGREP -q ".note.gnu.property[ \t]+NOTE.*$align$" "$1"
     then
        echo "Wrong .note.gnu.property alignment in $1:"
-       egrep ".note.gnu.property[ \t]+NOTE.*$align" "$1"
+       $EGREP ".note.gnu.property[ \t]+NOTE.*$align" "$1"
        exit 1
     fi
 }
index 05488a60ad05fd014cacb73e45bbff19afb6e554..7ac804b770611ffa06dc0d4cf8e2381fab09643e 100755 (executable)
@@ -32,7 +32,7 @@ check()
 {
     file=$1
 
-    found=`egrep "\.gnu\.version.*" $file`
+    found=`$EGREP "\.gnu\.version.*" $file`
     if test -n "$found"; then
        echo "These section should not be in $file:"
        echo "$found"
index d32fb383c1ee3e4c8798f25113d48467b2d88e56..b73496bd423a79733f4be84ba8ef22bd91afb754 100755 (executable)
@@ -23,6 +23,6 @@
 
 set -e
 
-egrep -q "..debug_mac[ro|info][ ]+*" pr18689.stdout
+$EGREP -q "..debug_mac[ro|info][ ]+*" pr18689.stdout
 
 exit 0
index 4c94f0f4212931bb91b505f0f46272db32324f78..2d52fc4e00899738fcc21be37a9be63259723bce 100755 (executable)
@@ -26,7 +26,7 @@ set -e
 
 check()
 {
-    number_of_occurrence=`egrep "$2" ./$1 -o| wc -l`
+    number_of_occurrence=`$EGREP "$2" ./$1 -o| wc -l`
     if [ $number_of_occurrence != $3 ]
     then
        echo "$1: \"$2\" $3: Failed"
index 6e8a6f1ac7b1098913a0f174160bdbb59519ce73..f981f77e4182fb2259c361530ac6aeb4f262de39 100755 (executable)
@@ -25,7 +25,7 @@ set -e
 
 check()
 {
-    number_of_occurrence=`egrep "$2" ./$1 -o | wc -l`
+    number_of_occurrence=`$EGREP "$2" ./$1 -o | wc -l`
     if [ $number_of_occurrence != $3 ]
     then
        echo "$1: \"$2\" $3: Failed"
index 058e15eed328f4855967c6f7b0ec8310a89ae221..77d3bb7db8bb641350c409f58f1f786be10cd4a5 100755 (executable)
@@ -24,7 +24,7 @@
 
 match()
 {
-  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+  if ! $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "could not find '$1' in $2"
     exit 1
   fi
@@ -32,7 +32,7 @@ match()
 
 nomatch()
 {
-  if egrep "$1" "$2" >/dev/null 2>&1; then
+  if $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "found unexpected '$1' in $2"
     exit 1
   fi
index 4b7ac3d4a76d524e9e83a0f31f28035627a7cde2..3a5b07bd9ac124cfe118000447b63c6357a5c3c0 100755 (executable)
@@ -24,7 +24,7 @@
 
 match()
 {
-  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+  if ! $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "could not find '$1' in $2"
     exit 1
   fi
@@ -32,7 +32,7 @@ match()
 
 nomatch()
 {
-  if egrep "$1" "$2" >/dev/null 2>&1; then
+  if $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "found unexpected '$1' in $2"
     exit 1
   fi
index 7b2968e63d50d39744d4b6479f986641cccaba46..399a34110f09fcb87bd2210745ce9b37e9508259 100755 (executable)
@@ -25,7 +25,7 @@
 
 match()
 {
-  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+  if ! $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "could not find '$1' in $2"
     exit 1
   fi
@@ -33,7 +33,7 @@ match()
 
 nomatch()
 {
-  if egrep "$1" "$2" >/dev/null 2>&1; then
+  if $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "found unexpected '$1' in $2"
     exit 1
   fi
index afaebc31bedcca21683fe23397778ecd024c43b7..7f186e0851c21270d15bdaf96159dd9be19a6fa4 100755 (executable)
@@ -24,7 +24,7 @@
 
 match()
 {
-  if ! egrep "$1" "$2" >/dev/null 2>&1; then
+  if ! $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "could not find '$1' in $2"
     exit 1
   fi
@@ -32,7 +32,7 @@ match()
 
 nomatch()
 {
-  if egrep "$1" "$2" >/dev/null 2>&1; then
+  if $EGREP "$1" "$2" >/dev/null 2>&1; then
     echo 1>&2 "found unexpected '$1' in $2"
     exit 1
   fi
index a8c2bddc5937cd4b36c79943977b2b472fcd6118..cb75d366ebec53f711ec845af19b48ee22111616 100755 (executable)
@@ -24,7 +24,7 @@
 
 check()
 {
-    if ! egrep -q "$2" "$1"
+    if ! $EGREP -q "$2" "$1"
     then
        echo "Did not find expected symbol in $1:"
        echo "   $2"
index 24fd69a97e0896d6b96b3275b3ade09190730439..e75f072f8fac23a9092e322dd66887fb0fc744aa 100755 (executable)
@@ -5085,7 +5085,7 @@ else
       # Check to see if the program is GNU ld.  I'd rather use --version,
       # but apparently some GNU ld's only accept -v.
       # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | $EGREP '(GNU|with BFD)' > /dev/null; then
        test "$with_gnu_ld" != no && break
       else
        test "$with_gnu_ld" != yes && break
@@ -5113,7 +5113,7 @@ if ${acl_cv_prog_gnu_ld+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+if $LD -v 2>&1 </dev/null | $EGREP '(GNU|with BFD)' 1>&5; then
   acl_cv_prog_gnu_ld=yes
 else
   acl_cv_prog_gnu_ld=no
index f6d47262318687fa5db6a5bc811e3d1a993fa922..9af6bb9fd92a8f1c229180c903b87c886c333658 100644 (file)
@@ -109,7 +109,9 @@ proc test_ar { test lib object expect } {
        return
     }
 
-    set cmd "$nm --print-armap $tmpdir/$lib | grep \\\ in\\\  | egrep VERS\\\|bar\\\|foo | grep -v ^\\\\. | sort > $tmpdir/nm.out"
+    set cmd "$nm --print-armap $tmpdir/$lib | grep \" in \" | grep \"VERS
+bar
+foo\" | grep -v ^\\\\. | sort > $tmpdir/nm.out"
     verbose -log $cmd
     catch "exec $cmd" exec_output
     if [string match "" $exec_output] then {