Use __asm__ rather than asm in gold testsuite
[deliverable/binutils-gdb.git] / gold / testsuite / icf_safe_test.sh
index f77559ce22c05e2d1df5dff7f87c54d139d7da06..3320e3e1dd1fb751bab83702b50a7ba07b76e0d8 100755 (executable)
@@ -1,6 +1,8 @@
+#!/bin/sh
+
 # icf_safe_test.sh -- test --icf=safe
 
-# Copyright 2009 Free Software Foundation, Inc.
+# Copyright (C) 2009-2020 Free Software Foundation, Inc.
 # Written by Sriraman Tallam <tmsriram@google.com>.
 
 # This file is part of gold.
 
 # The goal of this program is to verify if --icf=safe  works as expected.
 # File icf_safe_test.cc is in this test. This program checks if only
-# ctors and dtors are folded.
+# ctors and dtors are folded, except for x86 (32 and 64 bit), which
+# uses relocation types to detect if function pointers are taken.
+
+set -e
 
 check_nofold()
 {
@@ -37,14 +42,33 @@ check_nofold()
 
 check_fold()
 {
-    func_addr_1=`grep $2 $1 | awk '{print $1}'`
-    func_addr_2=`grep $3 $1 | awk '{print $1}'`
-    if [ $func_addr_1 != $func_addr_2 ]
+    awk "
+BEGIN { discard = 0; }
+/^Discarded input/ { discard = 1; }
+/^Memory map/ { discard = 0; }
+/.*\\.text\\..*($2|$3).*/ { act[discard] = act[discard] \" \" \$0; }
+END {
+      # printf \"kept\" act[0] \"\\nfolded\" act[1] \"\\n\";
+      if (length(act[0]) == 0 || length(act[1]) == 0)
+       {
+         printf \"Safe Identical Code Folding did not fold $2 and $3\\n\"
+         exit 1;
+       }
+    }" $1
+}
+
+arch_specific_safe_fold()
+{
+    if grep -q -e "Advanced Micro Devices X86-64" -e "Intel 80386" -e "ARM" -e "TILE" -e "PowerPC" -e "AArch64" -e "IBM S/390" $2;
     then
-        echo "Safe Identical Code Folding did not fold " $2 "and" $3
-       exit 1
+      check_fold $3 $4 $5
+    else
+      check_nofold $1 $4 $5
     fi
 }
 
-check_nofold icf_safe_test.stdout "kept_func_1" "kept_func_2"
-check_fold   icf_safe_test.stdout "_ZN1AD1Ev" "_ZN1AC1Ev"
+arch_specific_safe_fold icf_safe_test_1.stdout icf_safe_test_2.stdout \
+  icf_safe_test.map "kept_func_1" "kept_func_2"
+check_fold   icf_safe_test.map "_ZN1AD2Ev" "_ZN1AC2Ev"
+check_nofold icf_safe_test_1.stdout "kept_func_3" "kept_func_1"
+check_nofold icf_safe_test_1.stdout "kept_func_3" "kept_func_2"
This page took 0.024086 seconds and 4 git commands to generate.