aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgenii Stepanov <eugenis@google.com>2016-03-03 11:36:36 -0800
committerCary Coutant <ccoutant@gmail.com>2016-03-03 11:42:13 -0800
commit95ecdfbfcbf508919652a0254ee2b8c6572a949e (patch)
tree826f8608795c4781115a6c508a498d61795cd03d
parentbdf7e23048b68171c01f2498cc46670a76e68c4d (diff)
downloadgdb-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.
-rw-r--r--gold/ChangeLog9
-rw-r--r--gold/plugin.cc31
-rw-r--r--gold/testsuite/Makefile.am16
-rw-r--r--gold/testsuite/Makefile.in56
-rw-r--r--gold/testsuite/plugin_start_lib_test.c3
-rw-r--r--gold/testsuite/plugin_start_lib_test_2.c2
-rw-r--r--gold/testsuite/plugin_test.c17
-rwxr-xr-xgold/testsuite/plugin_test_start_lib.sh52
-rw-r--r--include/ChangeLog4
-rw-r--r--include/plugin-api.h3
10 files changed, 175 insertions, 18 deletions
diff --git a/gold/ChangeLog b/gold/ChangeLog
index 53c1ceb..2d8193a 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,12 @@
+2015-03-03 Evgenii Stepanov <eugenis@google.com>
+
+ * 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.
+
2016-02-26 Egor Kochetov <egor.kochetov@intel.com>
Cary Coutant <ccoutant@gmail.com>
diff --git a/gold/plugin.cc b/gold/plugin.cc
index c01e4cd..4aeb3ea 100644
--- a/gold/plugin.cc
+++ b/gold/plugin.cc
@@ -112,6 +112,9 @@ static enum ld_plugin_status
get_symbols_v2(const void *handle, int nsyms, struct ld_plugin_symbol *syms);
static enum ld_plugin_status
+get_symbols_v3(const void *handle, int nsyms, struct ld_plugin_symbol *syms);
+
+static enum ld_plugin_status
add_input_file(const char *pathname);
static enum ld_plugin_status
@@ -199,7 +202,7 @@ Plugin::load()
sscanf(ver, "%d.%d", &major, &minor);
// Allocate and populate a transfer vector.
- const int tv_fixed_size = 26;
+ const int tv_fixed_size = 27;
int tv_size = this->args_.size() + tv_fixed_size;
ld_plugin_tv* tv = new ld_plugin_tv[tv_size];
@@ -277,6 +280,10 @@ Plugin::load()
tv[i].tv_u.tv_get_symbols = get_symbols_v2;
++i;
+ tv[i].tv_tag = LDPT_GET_SYMBOLS_V3;
+ tv[i].tv_u.tv_get_symbols = get_symbols_v3;
+
+ ++i;
tv[i].tv_tag = LDPT_ADD_INPUT_FILE;
tv[i].tv_u.tv_add_input_file = add_input_file;
@@ -937,7 +944,7 @@ Pluginobj::get_symbol_resolution_info(Symbol_table* symtab,
gold_assert(this->symbols_.size() == 0);
for (int i = 0; i < nsyms; i++)
syms[i].resolution = LDPR_PREEMPTED_REG;
- return LDPS_OK;
+ return version > 2 ? LDPS_NO_SYMS : LDPS_OK;
}
for (int i = 0; i < nsyms; i++)
@@ -1545,6 +1552,26 @@ get_symbols_v2(const void* handle, int nsyms, ld_plugin_symbol* syms)
return plugin_obj->get_symbol_resolution_info(symtab, nsyms, syms, 2);
}
+// Version 3 of the above. The only difference from v2 is that it
+// returns LDPS_NO_SYMS instead of LDPS_OK for the objects we never
+// decided to include.
+
+static enum ld_plugin_status
+get_symbols_v3(const void* handle, int nsyms, ld_plugin_symbol* syms)
+{
+ gold_assert(parameters->options().has_plugins());
+ Plugin_manager* plugins = parameters->options().plugins();
+ Object* obj = plugins->object(
+ static_cast<unsigned int>(reinterpret_cast<intptr_t>(handle)));
+ if (obj == NULL)
+ return LDPS_ERR;
+ Pluginobj* plugin_obj = obj->pluginobj();
+ if (plugin_obj == NULL)
+ return LDPS_ERR;
+ Symbol_table* symtab = plugins->symtab();
+ return plugin_obj->get_symbol_resolution_info(symtab, nsyms, syms, 3);
+}
+
// Add a new (real) input file generated by a plugin.
static enum ld_plugin_status
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
diff --git a/include/ChangeLog b/include/ChangeLog
index 97bba8b..6a54ba2 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2015-03-03 Evgenii Stepanov <eugenis@google.com>
+
+ * plugin-api.h (enum ld_plugin_tag): Add LDPT_GET_SYMBOLS_V3.
+
2016-02-26 H.J. Lu <hongjiu.lu@intel.com>
PR ld/19645
diff --git a/include/plugin-api.h b/include/plugin-api.h
index d7f9ee3..811e6e4 100644
--- a/include/plugin-api.h
+++ b/include/plugin-api.h
@@ -384,7 +384,8 @@ enum ld_plugin_tag
LDPT_ALLOW_SECTION_ORDERING = 24,
LDPT_GET_SYMBOLS_V2 = 25,
LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS = 26,
- LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27
+ LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27,
+ LDPT_GET_SYMBOLS_V3 = 28
};
/* The plugin transfer vector. */