diff options
author | Alan Modra <amodra@gmail.com> | 2013-03-12 22:46:19 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2013-03-12 22:46:19 +0000 |
commit | 4d9aa1551545dd5365d35a0844d3b7a5a35d02f3 (patch) | |
tree | a7dca097cb31fbcdcf14394961a242fc5c185850 | |
parent | 2d450646ca4c6972bf1d2c82c9e4453fd3381339 (diff) | |
download | gdb-4d9aa1551545dd5365d35a0844d3b7a5a35d02f3.zip gdb-4d9aa1551545dd5365d35a0844d3b7a5a35d02f3.tar.gz gdb-4d9aa1551545dd5365d35a0844d3b7a5a35d02f3.tar.bz2 |
* powerpc.cc (is_branch_reloc): Forward declare.
(Target_powerpc::do_can_check_for_function_pointers): New predicate.
(Target_powerpc::Scan::local_reloc_may_be_function_pointer): Return
false for 64-bit, true for 32-bit non-branch relocs.
(Target_powerpc::Scan::global_reloc_may_be_function_pointer): Likewise.
* testsuite/Makefile.am (icf_test): Use linker map file instead of
nm output.
(icf_safe_test): Generate linker map file as well as nm output.
(icf_safe_so_test): Likewise.
* testsuite/Makefile.in: Regenerate.
* testsuite/icf_test.sh: Parse linker map file to determine
section folding.
* testsuite/icf_safe_test.sh: Likewise. Expect folding for PowerPC.
* testsuite/icf_safe_so_test.sh: Likewise.
(X86_32_or_ARM_specific_safe_fold): Merge into..
(arch_specific_safe_fold): ..this.
(X86_64_specific_safe_fold): Delete unused function.
-rw-r--r-- | gold/ChangeLog | 20 | ||||
-rw-r--r-- | gold/powerpc.cc | 33 | ||||
-rw-r--r-- | gold/testsuite/Makefile.am | 56 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 43 | ||||
-rwxr-xr-x | gold/testsuite/icf_safe_so_test.sh | 51 | ||||
-rwxr-xr-x | gold/testsuite/icf_safe_test.sh | 30 | ||||
-rwxr-xr-x | gold/testsuite/icf_test.sh | 22 |
7 files changed, 166 insertions, 89 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog index e859a5e..6913ace 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,23 @@ +2013-03-13 Alan Modra <amodra@gmail.com> + + * powerpc.cc (is_branch_reloc): Forward declare. + (Target_powerpc::do_can_check_for_function_pointers): New predicate. + (Target_powerpc::Scan::local_reloc_may_be_function_pointer): Return + false for 64-bit, true for 32-bit non-branch relocs. + (Target_powerpc::Scan::global_reloc_may_be_function_pointer): Likewise. + * testsuite/Makefile.am (icf_test): Use linker map file instead of + nm output. + (icf_safe_test): Generate linker map file as well as nm output. + (icf_safe_so_test): Likewise. + * testsuite/Makefile.in: Regenerate. + * testsuite/icf_test.sh: Parse linker map file to determine + section folding. + * testsuite/icf_safe_test.sh: Likewise. Expect folding for PowerPC. + * testsuite/icf_safe_so_test.sh: Likewise. + (X86_32_or_ARM_specific_safe_fold): Merge into.. + (arch_specific_safe_fold): ..this. + (X86_64_specific_safe_fold): Delete unused function. + 2013-03-12 Alan Modra <amodra@gmail.com> * gc.h (gc_process_relocs): Look through function descriptors diff --git a/gold/powerpc.cc b/gold/powerpc.cc index b8ff86d..66109d2 100644 --- a/gold/powerpc.cc +++ b/gold/powerpc.cc @@ -62,6 +62,9 @@ class Output_data_glink; template<int size, bool big_endian> class Stub_table; +inline bool +is_branch_reloc(unsigned int r_type); + template<int size, bool big_endian> class Powerpc_relobj : public Sized_relobj_file<size, big_endian> { @@ -555,6 +558,10 @@ class Target_powerpc : public Sized_target<size, big_endian> void do_function_location(Symbol_location*) const; + bool + do_can_check_for_function_pointers() const + { return true; } + // Relocate a section. void relocate_section(const Relocate_info<size, big_endian>*, @@ -863,9 +870,18 @@ class Target_powerpc : public Sized_target<size, big_endian> unsigned int , Output_section* , const elfcpp::Rela<size, big_endian>& , - unsigned int , + unsigned int r_type, const elfcpp::Sym<size, big_endian>&) - { return false; } + { + // PowerPC64 .opd is not folded, so any identical function text + // may be folded and we'll still keep function addresses distinct. + // That means no reloc is of concern here. + if (size == 64) + return false; + // For 32-bit, conservatively assume anything but calls to + // function code might be taking the address of the function. + return !is_branch_reloc(r_type); + } inline bool global_reloc_may_be_function_pointer(Symbol_table* , Layout* , @@ -873,10 +889,15 @@ class Target_powerpc : public Sized_target<size, big_endian> Sized_relobj_file<size, big_endian>* , unsigned int , Output_section* , - const elfcpp::Rela<size, - big_endian>& , - unsigned int , Symbol*) - { return false; } + const elfcpp::Rela<size, big_endian>& , + unsigned int r_type, + Symbol*) + { + // As above. + if (size == 64) + return false; + return !is_branch_reloc(r_type); + } private: static void diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 481ed2c..5b5c86b 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -53,6 +53,26 @@ TEST_AR = $(top_builddir)/../binutils/ar TEST_NM = $(top_builddir)/../binutils/nm-new TEST_AS = $(top_builddir)/../gas/as-new +# Make the default target available to scripts as $DEFAULT_TARGET. +if DEFAULT_TARGET_ARM +export DEFAULT_TARGET = arm +endif +if DEFAULT_TARGET_I386 +export DEFAULT_TARGET = i386 +endif +if DEFAULT_TARGET_POWERPC +export DEFAULT_TARGET = powerpc +endif +if DEFAULT_TARGET_SPARC +export DEFAULT_TARGET = sparc +endif +if DEFAULT_TARGET_X86_64 +export DEFAULT_TARGET = x86_64 +endif +if DEFAULT_TARGET_TILEGX +export DEFAULT_TARGET = tilegx +endif + if PLUGINS LIBDL = -ldl endif @@ -201,14 +221,12 @@ pr14265.stdout: pr14265 $(TEST_NM) --format=bsd --numeric-sort $< > $@ check_SCRIPTS += icf_test.sh -check_DATA += icf_test.stdout -MOSTLYCLEANFILES += icf_test +check_DATA += icf_test.map +MOSTLYCLEANFILES += icf_test icf_test.map icf_test.o: icf_test.cc $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< -icf_test: icf_test.o gcctestdir/ld - $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_test.o -icf_test.stdout: icf_test - $(TEST_NM) -C icf_test > icf_test.stdout +icf_test icf_test.map: icf_test.o gcctestdir/ld + $(CXXLINK) -o icf_test -Bgcctestdir/ -Wl,--icf=all,-Map,icf_test.map icf_test.o check_SCRIPTS += icf_keep_unique_test.sh check_DATA += icf_keep_unique_test.stdout @@ -218,31 +236,31 @@ icf_keep_unique_test.o: icf_keep_unique_test.cc icf_keep_unique_test: icf_keep_unique_test.o gcctestdir/ld $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all -Wl,--keep-unique,_Z11unique_funcv icf_keep_unique_test.o icf_keep_unique_test.stdout: icf_keep_unique_test - $(TEST_NM) -C icf_keep_unique_test > icf_keep_unique_test.stdout + $(TEST_NM) -C $< > $@ check_SCRIPTS += icf_safe_test.sh -check_DATA += icf_safe_test_1.stdout icf_safe_test_2.stdout -MOSTLYCLEANFILES += icf_safe_test +check_DATA += icf_safe_test_1.stdout icf_safe_test_2.stdout icf_safe_test.map +MOSTLYCLEANFILES += icf_safe_test icf_safe_test.map icf_safe_test.o: icf_safe_test.cc $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< -icf_safe_test: icf_safe_test.o gcctestdir/ld - $(CXXLINK) -Bgcctestdir/ -Wl,--icf=safe icf_safe_test.o +icf_safe_test icf_safe_test.map: icf_safe_test.o gcctestdir/ld + $(CXXLINK) -o icf_safe_test -Bgcctestdir/ -Wl,--icf=safe,-Map,icf_safe_test.map icf_safe_test.o icf_safe_test_1.stdout: icf_safe_test - $(TEST_NM) icf_safe_test > icf_safe_test_1.stdout + $(TEST_NM) $< > $@ icf_safe_test_2.stdout: icf_safe_test - $(TEST_READELF) -h icf_safe_test > icf_safe_test_2.stdout + $(TEST_READELF) -h $< > $@ check_SCRIPTS += icf_safe_so_test.sh -check_DATA += icf_safe_so_test_1.stdout icf_safe_so_test_2.stdout -MOSTLYCLEANFILES += icf_safe_so_test +check_DATA += icf_safe_so_test_1.stdout icf_safe_so_test_2.stdout icf_safe_so_test.map +MOSTLYCLEANFILES += icf_safe_so_test icf_safe_so_test.map icf_safe_so_test.o: icf_safe_so_test.cc $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $< -icf_safe_so_test: icf_safe_so_test.o gcctestdir/ld - $(CXXLINK) -Bgcctestdir/ -Wl,--icf=safe icf_safe_so_test.o -fPIC -shared +icf_safe_so_test icf_safe_so_test.map: icf_safe_so_test.o gcctestdir/ld + $(CXXLINK) -o icf_safe_so_test -Bgcctestdir/ -Wl,--icf=safe,-Map,icf_safe_so_test.map icf_safe_so_test.o -fPIC -shared icf_safe_so_test_1.stdout: icf_safe_so_test - $(TEST_NM) icf_safe_so_test > icf_safe_so_test_1.stdout + $(TEST_NM) $< > $@ icf_safe_so_test_2.stdout: icf_safe_so_test - $(TEST_READELF) -h icf_safe_so_test > icf_safe_so_test_2.stdout + $(TEST_READELF) -h $< > $@ check_SCRIPTS += final_layout.sh check_DATA += final_layout.stdout diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index bfb7764..ec0acb9 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -105,12 +105,14 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_tls_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test.stdout \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout icf_test.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ pr14265.stdout icf_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_1.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test_2.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test_1.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test_2.stdout \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ text_section_grouping.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ text_section_no_grouping.stdout \ @@ -123,8 +125,11 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test.cmdline \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_comdat_test gc_tls_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ gc_orphan_section_test pr14265 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_keep_unique_test \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test icf_safe_so_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_test icf_test.map \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_keep_unique_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_test icf_safe_test.map \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ icf_safe_so_test.map \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout_sequence.txt \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ final_layout_script.lds \ @@ -4270,6 +4275,14 @@ uninstall-am: recheck recheck-html tags uninstall uninstall-am +# Make the default target available to scripts as $DEFAULT_TARGET. +@DEFAULT_TARGET_ARM_TRUE@export DEFAULT_TARGET = arm +@DEFAULT_TARGET_I386_TRUE@export DEFAULT_TARGET = i386 +@DEFAULT_TARGET_POWERPC_TRUE@export DEFAULT_TARGET = powerpc +@DEFAULT_TARGET_SPARC_TRUE@export DEFAULT_TARGET = sparc +@DEFAULT_TARGET_X86_64_TRUE@export DEFAULT_TARGET = x86_64 +@DEFAULT_TARGET_TILEGX_TRUE@export DEFAULT_TARGET = tilegx + # The unittests themselves # Infrastucture needed for the unittests: a directory where the linker @@ -4338,32 +4351,30 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) --format=bsd --numeric-sort $< > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.o: icf_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< -@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test: icf_test.o gcctestdir/ld -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all icf_test.o -@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test.stdout: icf_test -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C icf_test > icf_test.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_test icf_test.map: icf_test.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -o icf_test -Bgcctestdir/ -Wl,--icf=all,-Map,icf_test.map icf_test.o @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_keep_unique_test.o: icf_keep_unique_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_keep_unique_test: icf_keep_unique_test.o gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--icf=all -Wl,--keep-unique,_Z11unique_funcv icf_keep_unique_test.o @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_keep_unique_test.stdout: icf_keep_unique_test -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C icf_keep_unique_test > icf_keep_unique_test.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) -C $< > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_test.o: icf_safe_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -g -o $@ $< -@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_test: icf_safe_test.o gcctestdir/ld -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--icf=safe icf_safe_test.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_test icf_safe_test.map: icf_safe_test.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -o icf_safe_test -Bgcctestdir/ -Wl,--icf=safe,-Map,icf_safe_test.map icf_safe_test.o @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_test_1.stdout: icf_safe_test -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) icf_safe_test > icf_safe_test_1.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) $< > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_test_2.stdout: icf_safe_test -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -h icf_safe_test > icf_safe_test_2.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -h $< > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_so_test.o: icf_safe_so_test.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -fPIC -g -o $@ $< -@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_so_test: icf_safe_so_test.o gcctestdir/ld -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--icf=safe icf_safe_so_test.o -fPIC -shared +@GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_so_test icf_safe_so_test.map: icf_safe_so_test.o gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -o icf_safe_so_test -Bgcctestdir/ -Wl,--icf=safe,-Map,icf_safe_so_test.map icf_safe_so_test.o -fPIC -shared @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_so_test_1.stdout: icf_safe_so_test -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) icf_safe_so_test > icf_safe_so_test_1.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_NM) $< > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@icf_safe_so_test_2.stdout: icf_safe_so_test -@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -h icf_safe_so_test > icf_safe_so_test_2.stdout +@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -h $< > $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@final_layout.o: final_layout.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -O0 -c -ffunction-sections -fdata-sections -g -o $@ $< @GCC_TRUE@@NATIVE_LINKER_TRUE@final_layout_sequence.txt: diff --git a/gold/testsuite/icf_safe_so_test.sh b/gold/testsuite/icf_safe_so_test.sh index 2c88250..813248e 100755 --- a/gold/testsuite/icf_safe_so_test.sh +++ b/gold/testsuite/icf_safe_so_test.sh @@ -67,41 +67,36 @@ check_fold() return 0 fi - 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 ]; - then - echo "Safe Identical Code Folding did not fold " $2 "and" $3 - exit 1 - fi + 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; + } + }" $4 } arch_specific_safe_fold() { - if [ $1 -eq 0 ]; + grep -e "Intel 80386" -e "ARM" -e "PowerPC" $1 > /dev/null 2>&1 + if [ $? -eq 0 ]; then - check_fold $2 $3 $4 + check_fold $2 $4 $5 $3 else - check_nofold $2 $3 $4 + check_nofold $2 $4 $5 fi } -X86_32_or_ARM_specific_safe_fold() -{ - grep -e "Intel 80386" -e "ARM" $1 > /dev/null 2>&1 - arch_specific_safe_fold $? $2 $3 $4 -} - -X86_64_specific_safe_fold() -{ - grep -e "Advanced Micro Devices X86-64" $1 > /dev/null 2>&1 - arch_specific_safe_fold $? $2 $3 $4 -} - -X86_32_or_ARM_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout "foo_prot" "foo_hidden" -X86_32_or_ARM_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout "foo_prot" "foo_internal" -X86_32_or_ARM_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout "foo_prot" "foo_static" -X86_32_or_ARM_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout "foo_hidden" "foo_internal" -X86_32_or_ARM_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout "foo_hidden" "foo_static" -X86_32_or_ARM_specific_safe_fold icf_safe_so_test_2.stdout icf_safe_so_test_1.stdout "foo_internal" "foo_static" +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" diff --git a/gold/testsuite/icf_safe_test.sh b/gold/testsuite/icf_safe_test.sh index 3b2795a..fe224f6 100755 --- a/gold/testsuite/icf_safe_test.sh +++ b/gold/testsuite/icf_safe_test.sh @@ -40,28 +40,34 @@ 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 ] - then - echo "Safe Identical Code Folding did not fold " $2 "and" $3 - exit 1 - fi + 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() { - grep_x86=`grep -q -e "Advanced Micro Devices X86-64" -e "Intel 80386" -e "ARM" -e "TILE" $2` + grep_x86=`grep -q -e "Advanced Micro Devices X86-64" -e "Intel 80386" -e "ARM" -e "TILE" -e "PowerPC" $2` if [ $? -eq 0 ]; then - check_fold $1 $3 $4 + check_fold $3 $4 $5 else - check_nofold $1 $3 $4 + check_nofold $1 $4 $5 fi } arch_specific_safe_fold icf_safe_test_1.stdout icf_safe_test_2.stdout \ - "kept_func_1" "kept_func_2" -check_fold icf_safe_test_1.stdout "_ZN1AD1Ev" "_ZN1AC1Ev" + 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" diff --git a/gold/testsuite/icf_test.sh b/gold/testsuite/icf_test.sh index 5f1481c..50abd90 100755 --- a/gold/testsuite/icf_test.sh +++ b/gold/testsuite/icf_test.sh @@ -28,13 +28,19 @@ check() { - 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 ] - then - echo "Identical Code Folding failed to fold" $2 "and" $3 - exit 1 - fi + 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 \"Identical Code Folding did not fold $2 and $3\\n\" + exit 1; + } + }" $1 } -check icf_test.stdout "folded_func" "kept_func" +check icf_test.map "folded_func" "kept_func" |