This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] [GOLD] icf_safe_so_test


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c0ab2ae3cc9af434ba926015d82a39cdf42c70bf

commit c0ab2ae3cc9af434ba926015d82a39cdf42c70bf
Author: Alan Modra <amodra@gmail.com>
Date:   Sat Dec 8 13:22:51 2018 +1030

    [GOLD] icf_safe_so_test
    
    	PR 21128
    	* testsuite/icf_safe_so_test.sh (check_fold): Rewrite to check
    	multiple symbols at once.
    	(arch_specific_safe_fold): Likewise, and call with the four foo*
    	symbols expected to fold.

Diff:
---
 gold/ChangeLog                     |  8 ++++++
 gold/testsuite/icf_safe_so_test.sh | 54 +++++++++++++++++++++-----------------
 2 files changed, 38 insertions(+), 24 deletions(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 5c5bca2..b16c728 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,11 @@
+2018-12-08  Alan Modra  <amodra@gmail.com>
+
+	PR 21128
+	* testsuite/icf_safe_so_test.sh (check_fold): Rewrite to check
+	multiple symbols at once.
+	(arch_specific_safe_fold): Likewise, and call with the four foo*
+	symbols expected to fold.
+
 2018-12-06  H.J. Lu  <hongjiu.lu@intel.com>
 
 	* archive.cc (Archive::get_elf_object_for_member): Also print
diff --git a/gold/testsuite/icf_safe_so_test.sh b/gold/testsuite/icf_safe_so_test.sh
index 28600be..b1450b4 100755
--- a/gold/testsuite/icf_safe_so_test.sh
+++ b/gold/testsuite/icf_safe_so_test.sh
@@ -59,45 +59,51 @@ check_nofold()
 
 check_fold()
 {
-    if ! is_symbol_present $1 $2
-    then
-      return 0
-    fi
-
-    if ! is_symbol_present $1 $3
-    then
-      return 0
-    fi
-
+    map=$1
+    shift
+    num_syms=$#
+    save_IFS="$IFS"
+    IFS='|'
+    sym_patt="$*"
+    IFS="$save_IFS"
     awk "
 BEGIN { discard = 0; }
 /^Discarded input/ { discard = 1; }
 /^Memory map/ { discard = 0; }
-/.*\\.text\\..*($2|$3).*/ { act[discard] = act[discard] \" \" \$0; }
+/.*\\.text\\..*($sym_patt).*/ { act[discard] = act[discard] \" \" \$0; cnt[discard] = cnt[discard] + 1 }
 END {
-      # printf \"kept\" act[0] \"\\nfolded\" act[1] \"\\n\";
-      if (length(act[0]) == 0 || length(act[1]) == 0)
+      printf \"kept\" act[0] \"\\nfolded\" act[1] \"\\n\";
+      if (cnt[0] != 1 || cnt[1] != $num_syms - 1)
 	{
-	  printf \"Safe Identical Code Folding did not fold $2 and $3\\n\"
+	  printf \"Safe Identical Code Folding failed\\n\"
 	  exit 1;
 	}
-    }" $4
+    }" $map
 }
 
 arch_specific_safe_fold()
 {
     if grep -q -e "Intel 80386" -e "ARM" -e "PowerPC" $1;
     then
-      check_fold $2 $4 $5 $3
+	shift
+	shift
+	#echo check_fold $*
+	check_fold $*
     else
-      check_nofold $2 $4 $5
+	shift
+	nm_output=$1
+	shift
+	shift
+	while test $# -gt 1; do
+	    sym1=$1
+	    shift
+	    for sym2 in $*; do
+		#echo check_nofold $nm_output $sym1 $sym2
+		check_nofold $nm_output $sym1 $sym2
+	    done
+	done
     fi
 }
 
-arch_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout icf_safe_so_test.map "foo_prot" "foo_hidden"
-arch_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout icf_safe_so_test.map "foo_prot" "foo_internal"
-arch_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout icf_safe_so_test.map "foo_prot" "foo_static"
-arch_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout icf_safe_so_test.map "foo_hidden" "foo_internal"
-arch_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout icf_safe_so_test.map "foo_hidden" "foo_static"
-arch_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout icf_safe_so_test.map "foo_internal" "foo_static"
-check_nofold icf_safe_so_test_1.stdout "foo_glob" "bar_glob"
+arch_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout icf_safe_so_test.map foo_prot foo_hidden foo_internal foo_static
+check_nofold icf_safe_so_test_1.stdout foo_glob bar_glob


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]