diff options
author | Evgenii Stepanov <eugenis@google.com> | 2016-03-03 11:36:36 -0800 |
---|---|---|
committer | Cary Coutant <ccoutant@gmail.com> | 2016-03-03 11:42:13 -0800 |
commit | 95ecdfbfcbf508919652a0254ee2b8c6572a949e (patch) | |
tree | 826f8608795c4781115a6c508a498d61795cd03d /gold/testsuite | |
parent | bdf7e23048b68171c01f2498cc46670a76e68c4d (diff) | |
download | gdb-95ecdfbfcbf508919652a0254ee2b8c6572a949e.zip gdb-95ecdfbfcbf508919652a0254ee2b8c6572a949e.tar.gz gdb-95ecdfbfcbf508919652a0254ee2b8c6572a949e.tar.bz2 |
get_symbols() plugin API tweak to support --start-lib/--end-lib.
Let the plugin know that a file is not being included in the link by
returning LDPS_NO_SYMS from get_symbols().
include/
* plugin-api.h (enum ld_plugin_tag): Add LDPT_GET_SYMBOLS_V3.
gold/
* plugin.h (Pluginobj::get_symbol_resolution_info): Add version
parameter.
* plugin.cc (get_symbols_v3): New function.
(Plugin::load): Add LDPT_GET_SYMBOLS_V3.
(Pluginobj::get_symbol_resolution_info): Return LDPS_NO_SYMS when using
new version.
Diffstat (limited to 'gold/testsuite')
-rw-r--r-- | gold/testsuite/Makefile.am | 16 | ||||
-rw-r--r-- | gold/testsuite/Makefile.in | 56 | ||||
-rw-r--r-- | gold/testsuite/plugin_start_lib_test.c | 3 | ||||
-rw-r--r-- | gold/testsuite/plugin_start_lib_test_2.c | 2 | ||||
-rw-r--r-- | gold/testsuite/plugin_test.c | 17 | ||||
-rwxr-xr-x | gold/testsuite/plugin_test_start_lib.sh | 52 |
6 files changed, 131 insertions, 15 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 32906db..d78ec6c 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -2021,6 +2021,22 @@ plugin_test_thin.a: two_file_test_1.o two_file_test_1b.o two_file_test_2.o rm -f $@ $(TEST_AR) crT $@ $^ + +check_PROGRAMS += plugin_test_start_lib +check_SCRIPTS += plugin_test_start_lib.sh +check_DATA += plugin_test_start_lib.err +MOSTLYCLEANFILES += plugin_test_start_lib.err +plugin_test_start_lib: unused.o plugin_start_lib_test.o plugin_start_lib_test_2.syms gcctestdir/ld plugin_test.so + $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so" plugin_start_lib_test.o \ + -Wl,--start-lib plugin_start_lib_test_2.syms -Wl,--end-lib 2>plugin_test_start_lib.err +plugin_test_start_lib.err: plugin_test_start_lib + @touch plugin_test_start_lib.err + + +plugin_start_lib_test_2.syms: plugin_start_lib_test_2.o + $(TEST_READELF) -sW $< >$@ 2>/dev/null + + 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 fffd4ca..874d0bf 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -427,7 +427,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10 \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11 +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_start_lib @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_38 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.sh \ @@ -436,7 +437,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10.sh \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11.sh +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_start_lib.sh # Test that symbols known in the IR file but not in the replacement file # produce an unresolved symbol error. @@ -450,7 +452,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.o.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_9.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10.sections \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11.err \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_start_lib.err # Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av. @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_40 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \ @@ -464,7 +467,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ two_file_test_1c.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10.sections \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11.err \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_thin.a +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_thin.a \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_start_lib.err @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__append_41 = plugin_test_tls @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__append_42 = plugin_test_tls.sh @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__append_43 = plugin_test_tls.err @@ -1010,7 +1014,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_10$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_11$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_start_lib$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@@TLS_TRUE@am__EXEEXT_22 = plugin_test_tls$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_23 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test$(EXEEXT) \ @@ -1717,6 +1722,13 @@ plugin_test_8_DEPENDENCIES = libgoldtest.a ../libgold.a \ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) +plugin_test_start_lib_SOURCES = plugin_test_start_lib.c +plugin_test_start_lib_OBJECTS = plugin_test_start_lib.$(OBJEXT) +plugin_test_start_lib_LDADD = $(LDADD) +plugin_test_start_lib_DEPENDENCIES = libgoldtest.a ../libgold.a \ + ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) plugin_test_tls_SOURCES = plugin_test_tls.c plugin_test_tls_OBJECTS = plugin_test_tls.$(OBJEXT) plugin_test_tls_LDADD = $(LDADD) @@ -2183,12 +2195,12 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ plugin_test_10.c plugin_test_11.c plugin_test_2.c \ plugin_test_3.c plugin_test_4.c plugin_test_5.c \ plugin_test_6.c plugin_test_7.c plugin_test_8.c \ - plugin_test_tls.c $(protected_1_SOURCES) \ - $(protected_2_SOURCES) $(relro_now_test_SOURCES) \ - $(relro_script_test_SOURCES) $(relro_strip_test_SOURCES) \ - $(relro_test_SOURCES) $(script_test_1_SOURCES) \ - script_test_11.c script_test_12.c script_test_12i.c \ - $(script_test_2_SOURCES) script_test_3.c \ + plugin_test_start_lib.c plugin_test_tls.c \ + $(protected_1_SOURCES) $(protected_2_SOURCES) \ + $(relro_now_test_SOURCES) $(relro_script_test_SOURCES) \ + $(relro_strip_test_SOURCES) $(relro_test_SOURCES) \ + $(script_test_1_SOURCES) script_test_11.c script_test_12.c \ + script_test_12i.c $(script_test_2_SOURCES) script_test_3.c \ $(searched_file_test_SOURCES) start_lib_test.c \ $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \ $(tls_phdrs_script_test_SOURCES) $(tls_pic_test_SOURCES) \ @@ -3690,6 +3702,15 @@ pie_copyrelocs_test$(EXEEXT): $(pie_copyrelocs_test_OBJECTS) $(pie_copyrelocs_te @PLUGINS_FALSE@plugin_test_8$(EXEEXT): $(plugin_test_8_OBJECTS) $(plugin_test_8_DEPENDENCIES) @PLUGINS_FALSE@ @rm -f plugin_test_8$(EXEEXT) @PLUGINS_FALSE@ $(LINK) $(plugin_test_8_OBJECTS) $(plugin_test_8_LDADD) $(LIBS) +@GCC_FALSE@plugin_test_start_lib$(EXEEXT): $(plugin_test_start_lib_OBJECTS) $(plugin_test_start_lib_DEPENDENCIES) +@GCC_FALSE@ @rm -f plugin_test_start_lib$(EXEEXT) +@GCC_FALSE@ $(LINK) $(plugin_test_start_lib_OBJECTS) $(plugin_test_start_lib_LDADD) $(LIBS) +@NATIVE_LINKER_FALSE@plugin_test_start_lib$(EXEEXT): $(plugin_test_start_lib_OBJECTS) $(plugin_test_start_lib_DEPENDENCIES) +@NATIVE_LINKER_FALSE@ @rm -f plugin_test_start_lib$(EXEEXT) +@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_start_lib_OBJECTS) $(plugin_test_start_lib_LDADD) $(LIBS) +@PLUGINS_FALSE@plugin_test_start_lib$(EXEEXT): $(plugin_test_start_lib_OBJECTS) $(plugin_test_start_lib_DEPENDENCIES) +@PLUGINS_FALSE@ @rm -f plugin_test_start_lib$(EXEEXT) +@PLUGINS_FALSE@ $(LINK) $(plugin_test_start_lib_OBJECTS) $(plugin_test_start_lib_LDADD) $(LIBS) @GCC_FALSE@plugin_test_tls$(EXEEXT): $(plugin_test_tls_OBJECTS) $(plugin_test_tls_DEPENDENCIES) @GCC_FALSE@ @rm -f plugin_test_tls$(EXEEXT) @GCC_FALSE@ $(LINK) $(plugin_test_tls_OBJECTS) $(plugin_test_tls_LDADD) $(LIBS) @@ -4040,6 +4061,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_6.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_7.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_8.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_start_lib.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test_tls.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@ @@ -4533,6 +4555,8 @@ plugin_test_10.sh.log: plugin_test_10.sh @p='plugin_test_10.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_11.sh.log: plugin_test_11.sh @p='plugin_test_11.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +plugin_test_start_lib.sh.log: plugin_test_start_lib.sh + @p='plugin_test_start_lib.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_tls.sh.log: plugin_test_tls.sh @p='plugin_test_tls.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_final_layout.sh.log: plugin_final_layout.sh @@ -4841,6 +4865,8 @@ plugin_test_10.log: plugin_test_10$(EXEEXT) @p='plugin_test_10$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_11.log: plugin_test_11$(EXEEXT) @p='plugin_test_11$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +plugin_test_start_lib.log: plugin_test_start_lib$(EXEEXT) + @p='plugin_test_start_lib$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) plugin_test_tls.log: plugin_test_tls$(EXEEXT) @p='plugin_test_tls$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) exclude_libs_test.log: exclude_libs_test$(EXEEXT) @@ -6048,6 +6074,14 @@ uninstall-am: @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_thin.a: two_file_test_1.o two_file_test_1b.o two_file_test_2.o @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ rm -f $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_AR) crT $@ $^ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_start_lib: unused.o plugin_start_lib_test.o plugin_start_lib_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_start_lib_test.o \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ -Wl,--start-lib plugin_start_lib_test_2.syms -Wl,--end-lib 2>plugin_test_start_lib.err +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_start_lib.err: plugin_test_start_lib +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_start_lib.err + +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_start_lib_test_2.syms: plugin_start_lib_test_2.o +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null @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_start_lib_test.c b/gold/testsuite/plugin_start_lib_test.c new file mode 100644 index 0000000..03b2213 --- /dev/null +++ b/gold/testsuite/plugin_start_lib_test.c @@ -0,0 +1,3 @@ +int main(void) { + return 0; +} diff --git a/gold/testsuite/plugin_start_lib_test_2.c b/gold/testsuite/plugin_start_lib_test_2.c new file mode 100644 index 0000000..1edf995 --- /dev/null +++ b/gold/testsuite/plugin_start_lib_test_2.c @@ -0,0 +1,2 @@ +void foo(void); +void foo(void) {} diff --git a/gold/testsuite/plugin_test.c b/gold/testsuite/plugin_test.c index bf30d41..acfc7eb 100644 --- a/gold/testsuite/plugin_test.c +++ b/gold/testsuite/plugin_test.c @@ -57,6 +57,7 @@ static ld_plugin_register_cleanup register_cleanup_hook = NULL; static ld_plugin_add_symbols add_symbols = NULL; static ld_plugin_get_symbols get_symbols = NULL; static ld_plugin_get_symbols get_symbols_v2 = NULL; +static ld_plugin_get_symbols get_symbols_v3 = NULL; static ld_plugin_add_input_file add_input_file = NULL; static ld_plugin_message message = NULL; static ld_plugin_get_input_file get_input_file = NULL; @@ -124,6 +125,9 @@ onload(struct ld_plugin_tv *tv) case LDPT_GET_SYMBOLS_V2: get_symbols_v2 = entry->tv_u.tv_get_symbols; break; + case LDPT_GET_SYMBOLS_V3: + get_symbols_v3 = entry->tv_u.tv_get_symbols; + break; case LDPT_ADD_INPUT_FILE: add_input_file = entry->tv_u.tv_add_input_file; break; @@ -420,9 +424,9 @@ all_symbols_read_hook(void) (*message)(LDPL_INFO, "all symbols read hook called"); - if (get_symbols_v2 == NULL) + if (get_symbols_v3 == NULL) { - fprintf(stderr, "tv_get_symbols (v2) interface missing\n"); + fprintf(stderr, "tv_get_symbols (v3) interface missing\n"); return LDPS_ERR; } @@ -430,8 +434,13 @@ all_symbols_read_hook(void) claimed_file != NULL; claimed_file = claimed_file->next) { - (*get_symbols_v2)(claimed_file->handle, claimed_file->nsyms, - claimed_file->syms); + enum ld_plugin_status status = (*get_symbols_v3)( + claimed_file->handle, claimed_file->nsyms, claimed_file->syms); + if (status == LDPS_NO_SYMS) + { + (*message)(LDPL_INFO, "%s: no symbols", claimed_file->name); + continue; + } for (i = 0; i < claimed_file->nsyms; ++i) { diff --git a/gold/testsuite/plugin_test_start_lib.sh b/gold/testsuite/plugin_test_start_lib.sh new file mode 100755 index 0000000..5d9d431 --- /dev/null +++ b/gold/testsuite/plugin_test_start_lib.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +# plugin_test_start_lib.sh -- a test case for the plugin API. + +# Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free Software +# Foundation, Inc. +# Written by Evgenii Stepanov <eugenis@google.com>. + +# 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_1.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_start_lib.err "API version:" +check plugin_test_start_lib.err "gold version:" +check plugin_test_start_lib.err "plugin_start_lib_test.o: claim file hook called" +check plugin_test_start_lib.err "plugin_start_lib_test_2.syms: claim file hook called" +check plugin_test_start_lib.err "plugin_start_lib_test_2.syms: claiming file, adding 1 symbols" +check plugin_test_start_lib.err "all symbols read hook called" +check plugin_test_start_lib.err "plugin_start_lib_test_2.syms: no symbols" +check plugin_test_start_lib.err "cleanup hook called" + +exit 0 |