2012-07-17 Cary Coutant PR gold/14344 * configure: Regenerate. * configure.ac: Add check for -gpubnames support. * testsuite/Makefile.am (gdb_index_test_1): Add check for -gpubnames support; force -gno-pubnames. (gdb_index_test_2, gdb_index_test_3): Add check for -gpubnames support. (gdb_index_test_4): New test. * testsuite/Makefile.in: Regenerate. * testsuite/gdb_index_test_1.sh: Refactor code into common file. * testsuite/gdb_index_test_2.sh: Likewise. * testsuite/gdb_index_test_3.sh: Don't look for space after colon. * testsuite/gdb_index_test_4.sh: New script. * testsuite/gdb_index_test_comm.sh: New script with common code; don't look for space after colon. commit d6aece43a5a8d1e07886dda06776737a4b3f234b Author: Cary Coutant Date: Tue Jul 17 17:55:35 2012 -0700 Add configure check for -gpubnames support; test --gdb-index with -gpubnames. Fix --gdb-index tests to not look for space after colon. diff --git a/gold/configure.ac b/gold/configure.ac index 5e3dc06..05e807b 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -562,6 +562,13 @@ if test "$gold_cv_stat_st_mtim" = "yes"; then [Define if struct stat has a field st_mtim with timespec for mtime]) fi +dnl Check if gcc supports the -gpubnames option. +save_CXXFLAGS="$CXXFLAGS" +CXXFLAGS="$CXXFLAGS -gpubnames" +AC_COMPILE_IFELSE([int i;], [have_pubnames=yes], [have_pubnames=no]) +CXXFLAGS="$save_CXXFLAGS" +AM_CONDITIONAL(HAVE_PUBNAMES, test "$have_pubnames" = "yes") + AC_LANG_POP(C++) AC_CHECK_HEADERS(locale.h) diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 1c970a3..b8b88e8 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1967,12 +1967,14 @@ memory_test: memory_test.o gcctestdir/ld $(srcdir)/memory_test.t memory_test.stdout: memory_test $(TEST_READELF) -lWS $< > $@ -# Test that --gdb-index functions correctly. +if HAVE_PUBNAMES + +# Test that --gdb-index functions correctly without gcc-generated pubnames. check_SCRIPTS += gdb_index_test_1.sh check_DATA += gdb_index_test_1.stdout MOSTLYCLEANFILES += gdb_index_test_1.stdout gdb_index_test_1 gdb_index_test.o: gdb_index_test.cc - $(CXXCOMPILE) -O0 -g -c -o $@ $< + $(CXXCOMPILE) -O0 -g -gno-pubnames -c -o $@ $< gdb_index_test_1: gdb_index_test.o gcctestdir/ld $(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $< gdb_index_test_1.stdout: gdb_index_test_1 @@ -1980,6 +1982,7 @@ gdb_index_test_1.stdout: gdb_index_test_1 if HAVE_ZLIB +# Test that --gdb-index functions correctly with compressed debug sections. check_SCRIPTS += gdb_index_test_2.sh check_DATA += gdb_index_test_2.stdout MOSTLYCLEANFILES += gdb_index_test_2.stdout gdb_index_test_2 @@ -1992,7 +1995,7 @@ gdb_index_test_2.stdout: gdb_index_test_2 endif HAVE_ZLIB -# Another simple C test (DW_AT_high_pc encoding) for --gdb-index +# Another simple C test (DW_AT_high_pc encoding) for --gdb-index. check_SCRIPTS += gdb_index_test_3.sh check_DATA += gdb_index_test_3.stdout MOSTLYCLEANFILES += gdb_index_test_3.stdout gdb_index_test_3 @@ -2003,6 +2006,18 @@ gdb_index_test_3: gdb_index_test_3.o gcctestdir/ld gdb_index_test_3.stdout: gdb_index_test_3 $(TEST_READELF) --debug-dump=gdb_index $< > $@ +# Test that --gdb-index functions correctly with gcc-generated pubnames. +check_SCRIPTS += gdb_index_test_4.sh +check_DATA += gdb_index_test_4.stdout +MOSTLYCLEANFILES += gdb_index_test_4.stdout gdb_index_test_4 +gdb_index_test_pub.o: gdb_index_test.cc + $(CXXCOMPILE) -O0 -g -gpubnames -c -o $@ $< +gdb_index_test_4: gdb_index_test_pub.o gcctestdir/ld + $(CXXLINK) -Bgcctestdir/ -Wl,--gdb-index $< +gdb_index_test_4.stdout: gdb_index_test_4 + $(TEST_READELF) --debug-dump=gdb_index $< > $@ + +endif HAVE_PUBNAMES # End-to-end incremental linking tests. # Incremental linking is currently supported only on the x86_64 target. diff --git a/gold/testsuite/gdb_index_test_1.sh b/gold/testsuite/gdb_index_test_1.sh index 55f0699..f04c8a7 100755 --- a/gold/testsuite/gdb_index_test_1.sh +++ b/gold/testsuite/gdb_index_test_1.sh @@ -22,64 +22,4 @@ # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, # MA 02110-1301, USA. -check() -{ - if ! grep -q "$2" "$1" - then - echo "Did not find expected output:" - echo " $2" - echo "" - echo "Actual error output below:" - cat "$1" - exit 1 - fi -} - -STDOUT=gdb_index_test_1.stdout - -check $STDOUT "^Version [45]" - -# Look for the symbols we know should be in the symbol table. - -check $STDOUT "^\[ *[0-9]*\] (anonymous namespace): " -check $STDOUT "^\[ *[0-9]*\] (anonymous namespace)::c1_count: " -check $STDOUT "^\[ *[0-9]*\] (anonymous namespace)::c2_count: " -check $STDOUT "^\[ *[0-9]*\] bool: " -check $STDOUT "^\[ *[0-9]*\] check: " -check $STDOUT "^\[ *[0-9]*\] check >: " -check $STDOUT "^\[ *[0-9]*\] check >: " -# check $STDOUT "^\[ *[0-9]*\] check >: " -check $STDOUT "^\[ *[0-9]*\] double: " -check $STDOUT "^\[ *[0-9]*\] F_A: " -check $STDOUT "^\[ *[0-9]*\] F_B: " -check $STDOUT "^\[ *[0-9]*\] F_C: " -check $STDOUT "^\[ *[0-9]*\] int: " -check $STDOUT "^\[ *[0-9]*\] main: " -check $STDOUT "^\[ *[0-9]*\] one: " -check $STDOUT "^\[ *[0-9]*\] one::c1: " -check $STDOUT "^\[ *[0-9]*\] one::c1::~c1: " -check $STDOUT "^\[ *[0-9]*\] one::c1::c1: " -check $STDOUT "^\[ *[0-9]*\] one::c1::val: " -check $STDOUT "^\[ *[0-9]*\] one::c1v: " -check $STDOUT "^\[ *[0-9]*\] one::G_A: " -check $STDOUT "^\[ *[0-9]*\] one::G_B: " -check $STDOUT "^\[ *[0-9]*\] one::G_B: " -check $STDOUT "^\[ *[0-9]*\] two: " -check $STDOUT "^\[ *[0-9]*\] two::c2::~c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::val: " -check $STDOUT "^\[ *[0-9]*\] two::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::~c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::val: " -check $STDOUT "^\[ *[0-9]*\] two::c2::~c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::val: " -check $STDOUT "^\[ *[0-9]*\] two::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2v1: " -check $STDOUT "^\[ *[0-9]*\] two::c2v2: " -check $STDOUT "^\[ *[0-9]*\] anonymous_union_var: " -check $STDOUT "^\[ *[0-9]*\] inline_func_1: " - -exit 0 +exec ${srcdir}/gdb_index_test_comm.sh gdb_index_test_1.stdout diff --git a/gold/testsuite/gdb_index_test_2.sh b/gold/testsuite/gdb_index_test_2.sh index 725d547..e31aa42 100755 --- a/gold/testsuite/gdb_index_test_2.sh +++ b/gold/testsuite/gdb_index_test_2.sh @@ -22,64 +22,4 @@ # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, # MA 02110-1301, USA. -check() -{ - if ! grep -q "$2" "$1" - then - echo "Did not find expected output:" - echo " $2" - echo "" - echo "Actual error output below:" - cat "$1" - exit 1 - fi -} - -STDOUT=gdb_index_test_2.stdout - -check $STDOUT "^Version [45]" - -# Look for the symbols we know should be in the symbol table. - -check $STDOUT "^\[ *[0-9]*\] (anonymous namespace): " -check $STDOUT "^\[ *[0-9]*\] (anonymous namespace)::c1_count: " -check $STDOUT "^\[ *[0-9]*\] (anonymous namespace)::c2_count: " -check $STDOUT "^\[ *[0-9]*\] bool: " -check $STDOUT "^\[ *[0-9]*\] check: " -check $STDOUT "^\[ *[0-9]*\] check >: " -check $STDOUT "^\[ *[0-9]*\] check >: " -# check $STDOUT "^\[ *[0-9]*\] check >: " -check $STDOUT "^\[ *[0-9]*\] double: " -check $STDOUT "^\[ *[0-9]*\] F_A: " -check $STDOUT "^\[ *[0-9]*\] F_B: " -check $STDOUT "^\[ *[0-9]*\] F_C: " -check $STDOUT "^\[ *[0-9]*\] int: " -check $STDOUT "^\[ *[0-9]*\] main: " -check $STDOUT "^\[ *[0-9]*\] one: " -check $STDOUT "^\[ *[0-9]*\] one::c1: " -check $STDOUT "^\[ *[0-9]*\] one::c1::~c1: " -check $STDOUT "^\[ *[0-9]*\] one::c1::c1: " -check $STDOUT "^\[ *[0-9]*\] one::c1::val: " -check $STDOUT "^\[ *[0-9]*\] one::c1v: " -check $STDOUT "^\[ *[0-9]*\] one::G_A: " -check $STDOUT "^\[ *[0-9]*\] one::G_B: " -check $STDOUT "^\[ *[0-9]*\] one::G_B: " -check $STDOUT "^\[ *[0-9]*\] two: " -check $STDOUT "^\[ *[0-9]*\] two::c2::~c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::val: " -check $STDOUT "^\[ *[0-9]*\] two::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::~c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::val: " -check $STDOUT "^\[ *[0-9]*\] two::c2::~c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2::val: " -check $STDOUT "^\[ *[0-9]*\] two::c2: " -check $STDOUT "^\[ *[0-9]*\] two::c2v1: " -check $STDOUT "^\[ *[0-9]*\] two::c2v2: " -check $STDOUT "^\[ *[0-9]*\] anonymous_union_var: " -check $STDOUT "^\[ *[0-9]*\] inline_func_1: " - -exit 0 +exec ${srcdir}/gdb_index_test_comm.sh gdb_index_test_2.stdout diff --git a/gold/testsuite/gdb_index_test_3.sh b/gold/testsuite/gdb_index_test_3.sh index dd6ce7e..bd1500b 100755 --- a/gold/testsuite/gdb_index_test_3.sh +++ b/gold/testsuite/gdb_index_test_3.sh @@ -41,9 +41,9 @@ check $STDOUT "^Version [45]" # Look for the symbols we know should be in the symbol table. -check $STDOUT "^\[ *[0-9]*\] main: " -check $STDOUT "^\[ *[0-9]*\] check_int: " -check $STDOUT "^\[ *[0-9]*\] j: " -check $STDOUT "^\[ *[0-9]*\] int: " +check $STDOUT "^\[ *[0-9]*\] main:" +check $STDOUT "^\[ *[0-9]*\] check_int:" +check $STDOUT "^\[ *[0-9]*\] j:" +check $STDOUT "^\[ *[0-9]*\] int:" exit 0 diff --git a/gold/testsuite/gdb_index_test_4.sh b/gold/testsuite/gdb_index_test_4.sh new file mode 100755 index 0000000..44c8a9a --- /dev/null +++ b/gold/testsuite/gdb_index_test_4.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +# gdb_index_test_4.sh -- a test case for the --gdb-index option. + +# Copyright 2012 Free Software Foundation, Inc. +# Written by Cary Coutant . + +# This file is part of gold. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +exec ${srcdir}/gdb_index_test_comm.sh gdb_index_test_4.stdout diff --git a/gold/testsuite/gdb_index_test_comm.sh b/gold/testsuite/gdb_index_test_comm.sh new file mode 100755 index 0000000..4ab07b3 --- /dev/null +++ b/gold/testsuite/gdb_index_test_comm.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +# gdb_index_test_comm.sh -- common code for --gdb-index tests. + +# Copyright 2012 Free Software Foundation, Inc. +# Written by Cary Coutant . + +# This file is part of gold. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, +# MA 02110-1301, USA. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected output:" + echo " $2" + echo "" + echo "Actual error output below:" + cat "$1" + exit 1 + fi +} + +STDOUT="$1" + +check $STDOUT "^Version [45]" + +# Look for the symbols we know should be in the symbol table. + +check $STDOUT "^\[ *[0-9]*\] (anonymous namespace):" +check $STDOUT "^\[ *[0-9]*\] (anonymous namespace)::c1_count:" +check $STDOUT "^\[ *[0-9]*\] (anonymous namespace)::c2_count:" +check $STDOUT "^\[ *[0-9]*\] bool:" +check $STDOUT "^\[ *[0-9]*\] check:" +check $STDOUT "^\[ *[0-9]*\] check >:" +check $STDOUT "^\[ *[0-9]*\] check >:" +# check $STDOUT "^\[ *[0-9]*\] check >:" +check $STDOUT "^\[ *[0-9]*\] double:" +check $STDOUT "^\[ *[0-9]*\] F_A:" +check $STDOUT "^\[ *[0-9]*\] F_B:" +check $STDOUT "^\[ *[0-9]*\] F_C:" +check $STDOUT "^\[ *[0-9]*\] int:" +check $STDOUT "^\[ *[0-9]*\] main:" +check $STDOUT "^\[ *[0-9]*\] one:" +check $STDOUT "^\[ *[0-9]*\] one::c1:" +check $STDOUT "^\[ *[0-9]*\] one::c1::~c1:" +check $STDOUT "^\[ *[0-9]*\] one::c1::c1:" +check $STDOUT "^\[ *[0-9]*\] one::c1::val:" +check $STDOUT "^\[ *[0-9]*\] one::c1v:" +check $STDOUT "^\[ *[0-9]*\] one::G_A:" +check $STDOUT "^\[ *[0-9]*\] one::G_B:" +check $STDOUT "^\[ *[0-9]*\] one::G_B:" +check $STDOUT "^\[ *[0-9]*\] two:" +check $STDOUT "^\[ *[0-9]*\] two::c2::~c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2::c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2::val:" +check $STDOUT "^\[ *[0-9]*\] two::c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2::~c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2::c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2::val:" +check $STDOUT "^\[ *[0-9]*\] two::c2::~c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2::c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2::val:" +check $STDOUT "^\[ *[0-9]*\] two::c2:" +check $STDOUT "^\[ *[0-9]*\] two::c2v1:" +check $STDOUT "^\[ *[0-9]*\] two::c2v2:" +check $STDOUT "^\[ *[0-9]*\] anonymous_union_var:" +check $STDOUT "^\[ *[0-9]*\] inline_func_1:" + +exit 0