From be234d887ed5127f8a87aecb6e131679398485c1 Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 6 Apr 2010 21:56:24 +0000 Subject: gcc PR lto/42757 * plugin.cc (Pluginobj::get_symbol_resolution_info): Check for prevailing definitions of common symbols. * testsuite/plugin_test_6.sh: New test case. * testsuite/plugin_common_test_1.c: New test case. * testsuite/plugin_common_test_2.c: New test case. * testsuite/Makefile.am (plugin_test_6): New test case. * testsuite/Makefile.in: Regenerate. --- gold/ChangeLog | 11 +++++++ gold/plugin.cc | 4 +++ gold/testsuite/Makefile.am | 13 ++++++++ gold/testsuite/Makefile.in | 42 +++++++++++++++++++++---- gold/testsuite/plugin_common_test_1.c | 46 +++++++++++++++++++++++++++ gold/testsuite/plugin_common_test_2.c | 43 ++++++++++++++++++++++++++ gold/testsuite/plugin_test_6.sh | 58 +++++++++++++++++++++++++++++++++++ 7 files changed, 211 insertions(+), 6 deletions(-) create mode 100644 gold/testsuite/plugin_common_test_1.c create mode 100644 gold/testsuite/plugin_common_test_2.c create mode 100755 gold/testsuite/plugin_test_6.sh (limited to 'gold') diff --git a/gold/ChangeLog b/gold/ChangeLog index b97766c..42f1c02 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,14 @@ +2010-04-06 Cary Coutant + + gcc PR lto/42757 + * plugin.cc (Pluginobj::get_symbol_resolution_info): Check for + prevailing definitions of common symbols. + * testsuite/plugin_test_6.sh: New test case. + * testsuite/plugin_common_test_1.c: New test case. + * testsuite/plugin_common_test_2.c: New test case. + * testsuite/Makefile.am (plugin_test_6): New test case. + * testsuite/Makefile.in: Regenerate. + 2010-04-06 Nick Clifton * po/vi.po: New Vietnamese translation. diff --git a/gold/plugin.cc b/gold/plugin.cc index d9b4c59..2ee1301 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -503,6 +503,10 @@ Pluginobj::get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const // The original symbol was undefined or common. if (lsym->source() != Symbol::FROM_OBJECT) res = LDPR_RESOLVED_EXEC; + else if (lsym->object()->pluginobj() == this) + res = (is_visible_from_outside(lsym) + ? LDPR_PREVAILING_DEF + : LDPR_PREVAILING_DEF_IRONLY); else if (lsym->object()->pluginobj() != NULL) res = LDPR_RESOLVED_IR; else if (lsym->object()->is_dynamic()) diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index b4f97e9..3bc0ec8 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -1237,6 +1237,15 @@ check_PROGRAMS += plugin_test_5 plugin_test_5: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms unused.syms gcctestdir/ld plugin_test.so $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv",--gc-sections two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms unused.syms +check_PROGRAMS += plugin_test_6 +check_SCRIPTS += plugin_test_6.sh +check_DATA += plugin_test_6.err +MOSTLYCLEANFILES += plugin_test_6.err +plugin_test_6: plugin_common_test_1.syms plugin_common_test_2.syms gcctestdir/ld plugin_test.so + $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.syms plugin_common_test_2.syms 2>plugin_test_6.err +plugin_test_6.err: plugin_test_6 + @touch plugin_test_6.err + plugin_test.so: plugin_test.o $(LINK) -Bgcctestdir/ -shared plugin_test.o plugin_test.o: plugin_test.c @@ -1250,6 +1259,10 @@ two_file_test_1b.syms: two_file_test_1b.o $(TEST_READELF) -sW $< >$@ 2>/dev/null two_file_test_2.syms: two_file_test_2.o $(TEST_READELF) -sW $< >$@ 2>/dev/null +plugin_common_test_1.syms: plugin_common_test_1.o + $(TEST_READELF) -sW $< >$@ 2>/dev/null +plugin_common_test_2.syms: plugin_common_test_2.o + $(TEST_READELF) -sW $< >$@ 2>/dev/null empty.syms: @echo "" >$@ diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 86d7a5d..32a0db3 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -242,23 +242,27 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_5 +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_5 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_23 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.sh \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.sh +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6.sh @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_24 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.err \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.err \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6.err @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_25 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.a \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4.err \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ unused.c @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_26 = exclude_libs_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ local_labels_test \ @@ -470,7 +474,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_5$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_5$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_17 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ local_labels_test$(EXEEXT) \ @@ -733,6 +738,12 @@ plugin_test_5_LDADD = $(LDADD) plugin_test_5_DEPENDENCIES = libgoldtest.a ../libgold.a \ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +plugin_test_6_SOURCES = plugin_test_6.c +plugin_test_6_OBJECTS = plugin_test_6.$(OBJEXT) +plugin_test_6_LDADD = $(LDADD) +plugin_test_6_DEPENDENCIES = libgoldtest.a ../libgold.a \ + ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am__protected_1_SOURCES_DIST = protected_main_1.cc protected_main_2.cc \ protected_main_3.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@am_protected_1_OBJECTS = \ @@ -1165,7 +1176,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(many_sections_test_SOURCES) $(object_unittest_SOURCES) \ permission_test.c plugin_test_1.c plugin_test_2.c \ plugin_test_3.c plugin_test_4.c plugin_test_5.c \ - $(protected_1_SOURCES) $(protected_2_SOURCES) \ + plugin_test_6.c $(protected_1_SOURCES) $(protected_2_SOURCES) \ $(relro_script_test_SOURCES) $(relro_test_SOURCES) \ $(script_test_1_SOURCES) $(script_test_2_SOURCES) \ script_test_3.c $(searched_file_test_SOURCES) \ @@ -1225,7 +1236,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ many_sections_r_test.c $(am__many_sections_test_SOURCES_DIST) \ $(object_unittest_SOURCES) permission_test.c plugin_test_1.c \ plugin_test_2.c plugin_test_3.c plugin_test_4.c \ - plugin_test_5.c $(am__protected_1_SOURCES_DIST) \ + plugin_test_5.c plugin_test_6.c \ + $(am__protected_1_SOURCES_DIST) \ $(am__protected_2_SOURCES_DIST) \ $(am__relro_script_test_SOURCES_DIST) \ $(am__relro_test_SOURCES_DIST) \ @@ -2049,6 +2061,15 @@ object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENC @PLUGINS_FALSE@plugin_test_5$(EXEEXT): $(plugin_test_5_OBJECTS) $(plugin_test_5_DEPENDENCIES) @PLUGINS_FALSE@ @rm -f plugin_test_5$(EXEEXT) @PLUGINS_FALSE@ $(LINK) $(plugin_test_5_OBJECTS) $(plugin_test_5_LDADD) $(LIBS) +@GCC_FALSE@plugin_test_6$(EXEEXT): $(plugin_test_6_OBJECTS) $(plugin_test_6_DEPENDENCIES) +@GCC_FALSE@ @rm -f plugin_test_6$(EXEEXT) +@GCC_FALSE@ $(LINK) $(plugin_test_6_OBJECTS) $(plugin_test_6_LDADD) $(LIBS) +@NATIVE_LINKER_FALSE@plugin_test_6$(EXEEXT): $(plugin_test_6_OBJECTS) $(plugin_test_6_DEPENDENCIES) +@NATIVE_LINKER_FALSE@ @rm -f plugin_test_6$(EXEEXT) +@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_6_OBJECTS) $(plugin_test_6_LDADD) $(LIBS) +@PLUGINS_FALSE@plugin_test_6$(EXEEXT): $(plugin_test_6_OBJECTS) $(plugin_test_6_DEPENDENCIES) +@PLUGINS_FALSE@ @rm -f plugin_test_6$(EXEEXT) +@PLUGINS_FALSE@ $(LINK) $(plugin_test_6_OBJECTS) $(plugin_test_6_LDADD) $(LIBS) protected_1$(EXEEXT): $(protected_1_OBJECTS) $(protected_1_DEPENDENCIES) @rm -f protected_1$(EXEEXT) $(protected_1_LINK) $(protected_1_OBJECTS) $(protected_1_LDADD) $(LIBS) @@ -2279,6 +2300,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_5.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_6.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protected_main_2.Po@am__quote@ @@ -3148,6 +3170,10 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_AR) cr $@ $^ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_5: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms unused.syms gcctestdir/ld plugin_test.so @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv",--gc-sections two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms unused.syms +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_6: plugin_common_test_1.syms plugin_common_test_2.syms gcctestdir/ld plugin_test.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_common_test_1.syms plugin_common_test_2.syms 2>plugin_test_6.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_6.err: plugin_test_6 +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_6.err @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test.so: plugin_test.o @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(LINK) -Bgcctestdir/ -shared plugin_test.o @@ -3162,6 +3188,10 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_2.syms: two_file_test_2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_common_test_1.syms: plugin_common_test_1.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_common_test_2.syms: plugin_common_test_2.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@empty.syms: @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @echo "" >$@ diff --git a/gold/testsuite/plugin_common_test_1.c b/gold/testsuite/plugin_common_test_1.c new file mode 100644 index 0000000..cf9ca2f --- /dev/null +++ b/gold/testsuite/plugin_common_test_1.c @@ -0,0 +1,46 @@ +/* plugin_common_test_1.c -- test common symbol handling in plugins + + Copyright 2010 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. + + This is a test of common symbols in plugin objects. C1-C5 test + various combinations of tentative definitions, extern declarations, + and definitions. */ + +#include + +int c1; +int c2; +extern int c3; +int c4; +int c5 = 50; + +int +main (int argc __attribute__ ((unused)), char** argv __attribute__ ((unused))) +{ + foo(); + + assert (c1 == 10); + assert (c2 == 20); + assert (c3 == 30); + assert (c4 == 40); + + return 0; +} diff --git a/gold/testsuite/plugin_common_test_2.c b/gold/testsuite/plugin_common_test_2.c new file mode 100644 index 0000000..149fd45 --- /dev/null +++ b/gold/testsuite/plugin_common_test_2.c @@ -0,0 +1,43 @@ +/* plugin_common_test_2.c -- test common symbol handling in plugins + + Copyright 2010 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. + + This is a test of common symbols in plugin objects. C1-C5 test + various combinations of tentative definitions, extern declarations, + and definitions. */ + +#include + +int c1; +extern int c2; +int c3; +int c4 = 40; +int c5; + +void +foo () +{ + c1 = 10; + c2 = 20; + c3 = 30; + + assert (c5 == 50); +} diff --git a/gold/testsuite/plugin_test_6.sh b/gold/testsuite/plugin_test_6.sh new file mode 100755 index 0000000..9b368e7 --- /dev/null +++ b/gold/testsuite/plugin_test_6.sh @@ -0,0 +1,58 @@ +#!/bin/sh + +# plugin_test_6.sh -- a test case for the plugin API. + +# Copyright 2010 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. + +# This file goes with plugin_test_6.c, a simple plug-in library that +# exercises the basic interfaces and prints out version numbers and +# options passed to the plugin. + +check() +{ + if ! grep -q "$2" "$1" + then + echo "Did not find expected output in $1:" + echo " $2" + echo "" + echo "Actual output below:" + cat "$1" + exit 1 + fi +} + +check plugin_test_6.err "API version:" +check plugin_test_6.err "gold version:" +check plugin_test_6.err "plugin_common_test_1.syms: claim file hook called" +check plugin_test_6.err "plugin_common_test_2.syms: claim file hook called" +check plugin_test_6.err "plugin_common_test_1.syms: c1: PREVAILING_DEF_IRONLY" +check plugin_test_6.err "plugin_common_test_1.syms: c2: PREVAILING_DEF_IRONLY" +check plugin_test_6.err "plugin_common_test_1.syms: c3: RESOLVED_IR" +check plugin_test_6.err "plugin_common_test_1.syms: c4: RESOLVED_IR" +check plugin_test_6.err "plugin_common_test_1.syms: c5: PREVAILING_DEF_IRONLY" +check plugin_test_6.err "plugin_common_test_2.syms: c1: RESOLVED_IR" +check plugin_test_6.err "plugin_common_test_2.syms: c2: RESOLVED_IR" +check plugin_test_6.err "plugin_common_test_2.syms: c3: PREVAILING_DEF_IRONLY" +check plugin_test_6.err "plugin_common_test_2.syms: c4: PREVAILING_DEF_IRONLY" +check plugin_test_6.err "plugin_common_test_2.syms: c5: RESOLVED_IR" +check plugin_test_6.err "cleanup hook called" + +exit 0 -- cgit v1.1