From d66a9eb3f048c2143a5281fb967255b9445fb961 Mon Sep 17 00:00:00 2001 From: Cary Coutant Date: Tue, 23 Dec 2008 23:46:55 +0000 Subject: [PATCH] * plugin.cc (is_visible_from_outside): New function. (Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside so we don't return "IR only" status for exported symbols or -r links. * testsuite/Makefile.am (plugin_test_3): New test case. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test_3.sh: New file. --- gold/ChangeLog | 10 ++++++++ gold/plugin.cc | 17 ++++++++++++- gold/testsuite/Makefile.am | 9 +++++++ gold/testsuite/Makefile.in | 50 +++++++++++++++++++++++++++--------- gold/testsuite/plugin_test_3.sh | 56 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 129 insertions(+), 13 deletions(-) create mode 100755 gold/testsuite/plugin_test_3.sh diff --git a/gold/ChangeLog b/gold/ChangeLog index 493681e..9ce8cfd 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,13 @@ +2008-12-23 Cary Coutant + + * plugin.cc (is_visible_from_outside): New function. + (Pluginobj::get_symbol_resolution_info): Call is_visible_from_outside + so we don't return "IR only" status for exported symbols or -r links. + + * testsuite/Makefile.am (plugin_test_3): New test case. + * testsuite/Makefile.in: Regenerate. + * testsuite/plugin_test_3.sh: New file. + 2008-12-22 Cary Coutant * object.cc (Sized_relobj::layout_section): New function. diff --git a/gold/plugin.cc b/gold/plugin.cc index 498b344..c624ef1 100644 --- a/gold/plugin.cc +++ b/gold/plugin.cc @@ -372,6 +372,21 @@ Pluginobj::Pluginobj(const std::string& name, Input_file* input_file, { } +// Return TRUE if a defined symbol might be reachable from outside the +// universe of claimed objects. + +static inline bool +is_visible_from_outside(Symbol* lsym) +{ + if (lsym->in_real_elf()) + return true; + if (parameters->options().relocatable()) + return true; + if (parameters->options().export_dynamic() || parameters->options().shared()) + return lsym->is_externally_visible(); + return false; +} + // Get symbol resolution info. ld_plugin_status @@ -408,7 +423,7 @@ Pluginobj::get_symbol_resolution_info(int nsyms, ld_plugin_symbol* syms) const if (lsym->source() != Symbol::FROM_OBJECT) res = LDPR_PREEMPTED_REG; else if (lsym->object() == static_cast(this)) - res = (lsym->in_real_elf() + res = (is_visible_from_outside(lsym) ? LDPR_PREVAILING_DEF : LDPR_PREVAILING_DEF_IRONLY); else diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index c5f52ac..40daf1a 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -972,6 +972,15 @@ plugin_test_2: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms t plugin_test_2.err: plugin_test_2 @touch plugin_test_2.err +check_PROGRAMS += plugin_test_3 +check_SCRIPTS += plugin_test_3.sh +check_DATA += plugin_test_3.err +MOSTLYCLEANFILES += plugin_test_3.err +plugin_test_3: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms gcctestdir/ld plugin_test.so + $(CXXLINK) -Bgcctestdir/ -Wl,--export-dynamic -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms 2>plugin_test_3.err +plugin_test_3.err: plugin_test_3 + @touch plugin_test_3.err + plugin_test.so: plugin_test.o $(LINK) -Bgcctestdir/ -shared plugin_test.o plugin_test.o: plugin_test.c diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 5509ab1..a8644c1 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -292,16 +292,20 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \ @NATIVE_LINKER_FALSE@thin_archive_test_2_DEPENDENCIES = @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_20 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2 +@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@am__append_21 = \ @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_2.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.sh @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_22 = \ @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_2.err \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.err @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_23 = \ @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_2.err \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.err subdir = testsuite DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -402,7 +406,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_16 = plugin_test_1$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3$(EXEEXT) basic_pic_test_SOURCES = basic_pic_test.c basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT) basic_pic_test_LDADD = $(LDADD) @@ -571,6 +576,12 @@ plugin_test_2_LDADD = $(LDADD) plugin_test_2_DEPENDENCIES = libgoldtest.a ../libgold.a \ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +plugin_test_3_SOURCES = plugin_test_3.c +plugin_test_3_OBJECTS = plugin_test_3.$(OBJEXT) +plugin_test_3_LDADD = $(LDADD) +plugin_test_3_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 = \ @@ -854,12 +865,13 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ flagstest_o_specialfile_and_compress_debug_sections.c \ $(initpri1_SOURCES) $(justsyms_SOURCES) many_sections_r_test.c \ $(many_sections_test_SOURCES) $(object_unittest_SOURCES) \ - plugin_test_1.c plugin_test_2.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 \ - $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \ - $(tls_pic_test_SOURCES) $(tls_shared_gd_to_ie_test_SOURCES) \ + plugin_test_1.c plugin_test_2.c plugin_test_3.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 $(thin_archive_test_1_SOURCES) \ + $(thin_archive_test_2_SOURCES) $(tls_pic_test_SOURCES) \ + $(tls_shared_gd_to_ie_test_SOURCES) \ $(tls_shared_gnu2_gd_to_ie_test_SOURCES) \ $(tls_shared_gnu2_test_SOURCES) $(tls_shared_ie_test_SOURCES) \ $(tls_shared_nonpic_test_SOURCES) $(tls_shared_test_SOURCES) \ @@ -906,7 +918,7 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \ $(am__initpri1_SOURCES_DIST) $(am__justsyms_SOURCES_DIST) \ many_sections_r_test.c $(am__many_sections_test_SOURCES_DIST) \ $(object_unittest_SOURCES) plugin_test_1.c plugin_test_2.c \ - $(am__protected_1_SOURCES_DIST) \ + plugin_test_3.c $(am__protected_1_SOURCES_DIST) \ $(am__protected_2_SOURCES_DIST) \ $(am__relro_script_test_SOURCES_DIST) \ $(am__relro_test_SOURCES_DIST) \ @@ -1616,6 +1628,15 @@ object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENC @PLUGINS_FALSE@plugin_test_2$(EXEEXT): $(plugin_test_2_OBJECTS) $(plugin_test_2_DEPENDENCIES) @PLUGINS_FALSE@ @rm -f plugin_test_2$(EXEEXT) @PLUGINS_FALSE@ $(LINK) $(plugin_test_2_LDFLAGS) $(plugin_test_2_OBJECTS) $(plugin_test_2_LDADD) $(LIBS) +@GCC_FALSE@plugin_test_3$(EXEEXT): $(plugin_test_3_OBJECTS) $(plugin_test_3_DEPENDENCIES) +@GCC_FALSE@ @rm -f plugin_test_3$(EXEEXT) +@GCC_FALSE@ $(LINK) $(plugin_test_3_LDFLAGS) $(plugin_test_3_OBJECTS) $(plugin_test_3_LDADD) $(LIBS) +@NATIVE_LINKER_FALSE@plugin_test_3$(EXEEXT): $(plugin_test_3_OBJECTS) $(plugin_test_3_DEPENDENCIES) +@NATIVE_LINKER_FALSE@ @rm -f plugin_test_3$(EXEEXT) +@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_3_LDFLAGS) $(plugin_test_3_OBJECTS) $(plugin_test_3_LDADD) $(LIBS) +@PLUGINS_FALSE@plugin_test_3$(EXEEXT): $(plugin_test_3_OBJECTS) $(plugin_test_3_DEPENDENCIES) +@PLUGINS_FALSE@ @rm -f plugin_test_3$(EXEEXT) +@PLUGINS_FALSE@ $(LINK) $(plugin_test_3_LDFLAGS) $(plugin_test_3_OBJECTS) $(plugin_test_3_LDADD) $(LIBS) protected_1$(EXEEXT): $(protected_1_OBJECTS) $(protected_1_DEPENDENCIES) @rm -f protected_1$(EXEEXT) $(CXXLINK) $(protected_1_LDFLAGS) $(protected_1_OBJECTS) $(protected_1_LDADD) $(LIBS) @@ -1801,6 +1822,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/object_unittest.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_1.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_2.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_3.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@ @@ -2461,6 +2483,10 @@ uninstall-am: uninstall-info-am @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,-R,.,--plugin,"./plugin_test.so" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so 2>plugin_test_2.err @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_2.err: plugin_test_2 @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_2.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_3: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms gcctestdir/ld plugin_test.so +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--export-dynamic -Wl,--no-demangle,--plugin,"./plugin_test.so",--plugin-opt,"_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms empty.syms 2>plugin_test_3.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_3.err: plugin_test_3 +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_3.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 diff --git a/gold/testsuite/plugin_test_3.sh b/gold/testsuite/plugin_test_3.sh new file mode 100755 index 0000000..837595f --- /dev/null +++ b/gold/testsuite/plugin_test_3.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# plugin_test_3.sh -- a test case for the plugin API. + +# Copyright 2008 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.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_3.err "API version:" +check plugin_test_3.err "gold version:" +check plugin_test_3.err "option: _Z4f13iv" +check plugin_test_3.err "two_file_test_main.o: claim file hook called" +check plugin_test_3.err "two_file_test_1.syms: claim file hook called" +check plugin_test_3.err "two_file_test_1b.syms: claim file hook called" +check plugin_test_3.err "two_file_test_2.syms: claim file hook called" +check plugin_test_3.err "two_file_test_1.syms: _Z4f13iv: PREVAILING_DEF_REG" +check plugin_test_3.err "two_file_test_1.syms: _Z2t2v: PREVAILING_DEF_REG" +check plugin_test_3.err "two_file_test_1.syms: v2: RESOLVED_IR" +check plugin_test_3.err "two_file_test_1.syms: t17data: RESOLVED_IR" +check plugin_test_3.err "two_file_test_2.syms: _Z4f13iv: PREEMPTED_IR" +check plugin_test_3.err "cleanup hook called" + +exit 0 -- 2.7.4