aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorCary Coutant <ccoutant@google.com>2008-09-19 22:54:57 +0000
committerCary Coutant <ccoutant@google.com>2008-09-19 22:54:57 +0000
commit89fc34211be8b1d74b83e4e2b18cfa4b4cf65ba9 (patch)
treecd5675e9053bb0b9b68d98253003c08bc5e28bb9 /gold/testsuite
parent14fc49fb1561bd620e790080ad27ed3890780b42 (diff)
downloadgdb-89fc34211be8b1d74b83e4e2b18cfa4b4cf65ba9.zip
gdb-89fc34211be8b1d74b83e4e2b18cfa4b4cf65ba9.tar.gz
gdb-89fc34211be8b1d74b83e4e2b18cfa4b4cf65ba9.tar.bz2
Add plugin functionality for link-time optimization (LTO).
include/: * plugin-api.h: New file. gold/: * configure.ac (plugins): Add --enable-plugins option. * configure: Regenerate. * config.in: Regenerate. * Makefile.am (LIBDL): New variable. (CCFILES): Add plugin.cc. (HFILES): Add plugin.h. (ldadd_var): Add LIBDL. * Makefile.in: Regenerate. * archive.cc: Include "plugin.h". (Archive::setup): Don't preread archive symbols when using a plugin. (Archive::get_file_and_offset): Add memsize parameter. Change callers. (Archive::get_elf_object_for_member): Call plugin hooks for claiming files. (Archive::include_member): Add symbols from plugin objects. * archive.h (Archive::get_file_and_offset): Add memsize parameter. * descriptors.cc (Descriptors::open): Check for file descriptors abandoned by plugins. (Descriptors::claim_for_plugin): New function. * descriptors.h (Descriptors::claim_for_plugin): New function. (Open_descriptor::is_claimed): New field. (claim_descriptor_for_plugin): New function. * fileread.cc (File_read::claim_for_plugin): New function. * fileread.h (File_read::claim_for_plugin): New function. (File_read::descriptor): New function. * gold.cc: Include "plugin.h". (queue_initial_tasks): Add task to call plugin hooks for generating new object files. * main.cc: Include "plugin.h". (main): Load plugin libraries. * object.h (Pluginobj): Declare. (Object::pluginobj): New function. (Object::do_pluginobj): New function. (Object::set_target): New function. * options.cc: Include "plugin.h". (General_options::parse_plugin): New function. (General_options::General_options): Initialize plugins_ field. (General_options::add_plugin): New function. * options.h (Plugin_manager): Declare. (General_options): Add --plugin option. (General_options::has_plugins): New function. (General_options::plugins): New function. (General_options::add_plugin): New function. (General_options::plugins_): New field. * plugin.cc: New file. * plugin.h: New file. * readsyms.cc: Include "plugin.h". (Read_symbols::do_read_symbols): Check for archive before checking for ELF file. Call plugin hooks to claim files. * resolve.cc (Symbol_table::resolve): Record when symbol is referenced from a real object file; force override when processing replacement files. * symtab.cc (Symbol::init_fields): Initialize in_real_elf_ field. (Symbol::init_base_object): Likewise. (Symbol::init_base_output_data): Likewise. (Symbol::init_base_output_segment): Likewise. (Symbol::init_base_constant): Likewise. (Symbol::init_base_undefined): Likewise. (Symbol::output_section): Assert that object is not a plugin. (Symbol_table::add_from_pluginobj): New function. (Symbol_table::sized_finalize_symbol): Treat symbols from plugins as undefined. (Symbol_table::sized_write_globals): Likewise. (Symbol_table::add_from_pluginobj): Instantiate template. * symtab.h (Sized_pluginobj): Declare. (Symbol::in_real_elf): New function. (Symbol::set_in_real_elf): New function. (Symbol::in_real_elf_): New field. (Symbol_table::add_from_pluginobj): New function. * testsuite/Makefile.am (AM_CFLAGS): New variable. (LIBDL): New variable. (LDADD): Add LIBDL. (check_PROGRAMS): Add plugin_test_1 and plugin_test_2. (check_SCRIPTS): Add plugin_test_1.sh and plugin_test_2.sh. (check_DATA): Add plugin_test_1.err and plugin_test_2.err. (MOSTLYCLEANFILES): Likewise. * testsuite/Makefile.in: Regenerate. * testsuite/plugin_test.c: New file. * testsuite/plugin_test_1.sh: New file. * testsuite/plugin_test_2.sh: New file.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am43
-rw-r--r--gold/testsuite/Makefile.in170
-rw-r--r--gold/testsuite/plugin_test.c427
-rwxr-xr-xgold/testsuite/plugin_test_1.sh56
-rwxr-xr-xgold/testsuite/plugin_test_2.sh54
5 files changed, 711 insertions, 39 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 1f08b5a..14efd73 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -9,6 +9,7 @@ AUTOMAKE_OPTIONS =
# The two_file_test tests -fmerge-constants, so we simply always turn
# it on. This may need to be controlled by a configure option
# eventually.
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -fmerge-constants
AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) -fmerge-constants
INCLUDES = \
@@ -22,6 +23,10 @@ TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
TEST_STRIP = $(top_builddir)/../binutils/strip-new
+if PLUGINS
+LIBDL = -ldl
+endif
+
if THREADS
THREADSLIB = -lpthread
endif
@@ -57,7 +62,7 @@ libgoldtest_a_SOURCES = test.cc testmain.cc testfile.cc
DEPENDENCIES = \
libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP)
LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
- $(THREADSLIB)
+ $(THREADSLIB) $(LIBDL)
# The unittests themselves
@@ -897,5 +902,41 @@ script_test_4: basic_test.o gcctestdir/ld $(srcdir)/script_test_4.t
script_test_4.stdout: script_test_4
$(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+if PLUGINS
+
+check_PROGRAMS += plugin_test_1
+check_SCRIPTS += plugin_test_1.sh
+check_DATA += plugin_test_1.err
+MOSTLYCLEANFILES += plugin_test_1.err
+plugin_test_1: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
+ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so;_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
+plugin_test_1.err: plugin_test_1
+ @touch plugin_test_1.err
+
+check_PROGRAMS += plugin_test_2
+check_SCRIPTS += plugin_test_2.sh
+check_DATA += plugin_test_2.err
+MOSTLYCLEANFILES += plugin_test_2.err
+plugin_test_2: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so gcctestdir/ld plugin_test.so
+ $(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
+plugin_test_2.err: plugin_test_2
+ @touch plugin_test_2.err
+
+plugin_test.so: plugin_test.o
+ $(LINK) -Bgcctestdir/ -shared plugin_test.o
+plugin_test.o: plugin_test.c
+ $(COMPILE) -O0 -c -fpic -o $@ $<
+
+two_file_test_main.syms: two_file_test_main.o
+ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+two_file_test_1.syms: two_file_test_1.o
+ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+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
+
+endif PLUGINS
+
endif GCC
endif NATIVE_LINKER
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index e3d8dca..9860835 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -47,7 +47,8 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
$(am__EXEEXT_4) $(am__EXEEXT_5) $(am__EXEEXT_6) \
$(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \
$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \
- $(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15)
+ $(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \
+ $(am__EXEEXT_16)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_1 = basic_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_static_test basic_pic_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ basic_static_pic_test \
@@ -66,33 +67,39 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_relocatable_test
@GCC_FALSE@constructor_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@constructor_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@constructor_static_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@constructor_static_test_DEPENDENCIES = \
@NATIVE_LINKER_FALSE@ libgoldtest.a ../libgold.a \
@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@two_file_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@two_file_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@two_file_static_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@two_file_static_test_DEPENDENCIES = \
@NATIVE_LINKER_FALSE@ libgoldtest.a ../libgold.a \
@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
# The nonpic tests will fail on platforms which can not put non-PIC
@@ -116,32 +123,37 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test weak_undef_test
@GCC_FALSE@common_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@common_test_1_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@exception_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@exception_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@exception_static_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@exception_static_test_DEPENDENCIES = \
@NATIVE_LINKER_FALSE@ libgoldtest.a ../libgold.a \
@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@weak_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@weak_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_4 = weak_undef_nonpic_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_5 = weak_alias_test weak_plt \
@@ -187,10 +199,12 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_r_test
@GCC_FALSE@many_sections_test_DEPENDENCIES = libgoldtest.a \
@GCC_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
-@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@many_sections_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_14 = many_sections_define.h \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_check.h
@@ -199,13 +213,15 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@CONSTRUCTOR_PRIORITY_FALSE@ ../libgold.a \
@CONSTRUCTOR_PRIORITY_FALSE@ ../../libiberty/libiberty.a \
@CONSTRUCTOR_PRIORITY_FALSE@ $(am__DEPENDENCIES_1) \
+@CONSTRUCTOR_PRIORITY_FALSE@ $(am__DEPENDENCIES_1) \
@CONSTRUCTOR_PRIORITY_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@initpri1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@initpri1_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_16 = debug_msg.err \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ debug_msg_so.err \
@@ -235,32 +251,48 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3
@GCC_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@script_test_1_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@script_test_2_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@script_test_2_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@justsyms_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@justsyms_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@GCC_FALSE@binary_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
-@GCC_FALSE@ $(am__DEPENDENCIES_1)
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@NATIVE_LINKER_FALSE@binary_test_DEPENDENCIES = libgoldtest.a \
@NATIVE_LINKER_FALSE@ ../libgold.a ../../libiberty/libiberty.a \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
+@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@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@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@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
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -358,31 +390,33 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ script_test_3$(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)
basic_pic_test_SOURCES = basic_pic_test.c
basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT)
basic_pic_test_LDADD = $(LDADD)
am__DEPENDENCIES_1 =
basic_pic_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
basic_static_pic_test_SOURCES = basic_static_pic_test.c
basic_static_pic_test_OBJECTS = basic_static_pic_test.$(OBJEXT)
basic_static_pic_test_LDADD = $(LDADD)
basic_static_pic_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
basic_static_test_SOURCES = basic_static_test.c
basic_static_test_OBJECTS = basic_static_test.$(OBJEXT)
basic_static_test_LDADD = $(LDADD)
basic_static_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
basic_test_SOURCES = basic_test.c
basic_test_OBJECTS = basic_test.$(OBJEXT)
basic_test_LDADD = $(LDADD)
basic_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__binary_test_SOURCES_DIST = binary_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_binary_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ binary_test.$(OBJEXT)
@@ -393,7 +427,7 @@ binary_unittest_OBJECTS = $(am_binary_unittest_OBJECTS)
binary_unittest_LDADD = $(LDADD)
binary_unittest_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__common_test_1_SOURCES_DIST = common_test_1.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_common_test_1_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ common_test_1.$(OBJEXT)
@@ -472,13 +506,13 @@ flagstest_compress_debug_sections_OBJECTS = \
flagstest_compress_debug_sections_LDADD = $(LDADD)
flagstest_compress_debug_sections_DEPENDENCIES = libgoldtest.a \
../libgold.a ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
flagstest_o_specialfile_SOURCES = flagstest_o_specialfile.c
flagstest_o_specialfile_OBJECTS = flagstest_o_specialfile.$(OBJEXT)
flagstest_o_specialfile_LDADD = $(LDADD)
flagstest_o_specialfile_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
flagstest_o_specialfile_and_compress_debug_sections_SOURCES = \
flagstest_o_specialfile_and_compress_debug_sections.c
flagstest_o_specialfile_and_compress_debug_sections_OBJECTS = \
@@ -486,7 +520,8 @@ flagstest_o_specialfile_and_compress_debug_sections_OBJECTS = \
flagstest_o_specialfile_and_compress_debug_sections_LDADD = $(LDADD)
flagstest_o_specialfile_and_compress_debug_sections_DEPENDENCIES = \
libgoldtest.a ../libgold.a ../../libiberty/libiberty.a \
- $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
am__initpri1_SOURCES_DIST = initpri1.c
@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_initpri1_OBJECTS = initpri1.$(OBJEXT)
initpri1_OBJECTS = $(am_initpri1_OBJECTS)
@@ -501,7 +536,7 @@ many_sections_r_test_OBJECTS = many_sections_r_test.$(OBJEXT)
many_sections_r_test_LDADD = $(LDADD)
many_sections_r_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__many_sections_test_SOURCES_DIST = many_sections_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_many_sections_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_test.$(OBJEXT)
@@ -512,7 +547,19 @@ object_unittest_OBJECTS = $(am_object_unittest_OBJECTS)
object_unittest_LDADD = $(LDADD)
object_unittest_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+plugin_test_1_SOURCES = plugin_test_1.c
+plugin_test_1_OBJECTS = plugin_test_1.$(OBJEXT)
+plugin_test_1_LDADD = $(LDADD)
+plugin_test_1_DEPENDENCIES = libgoldtest.a ../libgold.a \
+ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+plugin_test_2_SOURCES = plugin_test_2.c
+plugin_test_2_OBJECTS = plugin_test_2.$(OBJEXT)
+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)
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 = \
@@ -551,7 +598,7 @@ script_test_3_OBJECTS = script_test_3.$(OBJEXT)
script_test_3_LDADD = $(LDADD)
script_test_3_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__tls_pic_test_SOURCES_DIST = tls_test_main.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am_tls_pic_test_OBJECTS = tls_test_main.$(OBJEXT)
tls_pic_test_OBJECTS = $(am_tls_pic_test_OBJECTS)
@@ -708,7 +755,7 @@ two_file_strip_test_OBJECTS = two_file_strip_test.$(OBJEXT)
two_file_strip_test_LDADD = $(LDADD)
two_file_strip_test_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__two_file_test_SOURCES_DIST = two_file_test_1.cc \
two_file_test_1b.cc two_file_test_2.cc two_file_test_main.cc \
two_file_test.h
@@ -748,7 +795,7 @@ weak_plt_OBJECTS = weak_plt.$(OBJEXT)
weak_plt_LDADD = $(LDADD)
weak_plt_DEPENDENCIES = libgoldtest.a ../libgold.a \
../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__weak_test_SOURCES_DIST = weak_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_weak_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test.$(OBJEXT)
@@ -788,11 +835,11 @@ 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) \
- $(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 $(tls_pic_test_SOURCES) \
- $(tls_shared_gd_to_ie_test_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 \
+ $(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) \
@@ -838,7 +885,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
flagstest_o_specialfile_and_compress_debug_sections.c \
$(am__initpri1_SOURCES_DIST) $(am__justsyms_SOURCES_DIST) \
many_sections_r_test.c $(am__many_sections_test_SOURCES_DIST) \
- $(object_unittest_SOURCES) $(am__protected_1_SOURCES_DIST) \
+ $(object_unittest_SOURCES) plugin_test_1.c plugin_test_2.c \
+ $(am__protected_1_SOURCES_DIST) \
$(am__protected_2_SOURCES_DIST) \
$(am__relro_script_test_SOURCES_DIST) \
$(am__relro_test_SOURCES_DIST) \
@@ -954,6 +1002,8 @@ PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
POSUB = @POSUB@
RANDOM_SEED_CFLAGS = @RANDOM_SEED_CFLAGS@
RANLIB = @RANLIB@
@@ -1027,6 +1077,7 @@ AUTOMAKE_OPTIONS =
# The two_file_test tests -fmerge-constants, so we simply always turn
# it on. This may need to be controlled by a configure option
# eventually.
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -fmerge-constants
AM_CXXFLAGS = $(WARN_CXXFLAGS) $(LFS_CFLAGS) -fmerge-constants
INCLUDES = \
-I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../../include \
@@ -1038,6 +1089,7 @@ TEST_READELF = $(top_builddir)/../binutils/readelf
TEST_OBJDUMP = $(top_builddir)/../binutils/objdump
TEST_CXXFILT = $(top_builddir)/../binutils/cxxfilt
TEST_STRIP = $(top_builddir)/../binutils/strip-new
+@PLUGINS_TRUE@LIBDL = -ldl
@THREADS_TRUE@THREADSLIB = -lpthread
@OMP_SUPPORT_TRUE@TLS_TEST_C_CFLAGS = -fopenmp
@@ -1045,13 +1097,13 @@ TEST_STRIP = $(top_builddir)/../binutils/strip-new
# .o's), but not all of them (such as .so's and .err files). We
# improve on that here. automake-1.9 info docs say "mostlyclean" is
# the right choice for files 'make' builds that people rebuild.
-MOSTLYCLEANFILES = *.so $(am__append_16)
+MOSTLYCLEANFILES = *.so $(am__append_16) $(am__append_23)
# We will add to these later, for each individual test. Note
# that we add each test under check_SCRIPTS or check_PROGRAMS;
# the TESTS variable is automatically populated from these.
-check_SCRIPTS = $(am__append_6)
-check_DATA = $(am__append_7)
+check_SCRIPTS = $(am__append_6) $(am__append_21)
+check_DATA = $(am__append_7) $(am__append_22)
BUILT_SOURCES = $(am__append_14)
TESTS = $(check_SCRIPTS) $(check_PROGRAMS)
@@ -1065,7 +1117,7 @@ DEPENDENCIES = \
libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL_DEP)
LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \
- $(THREADSLIB)
+ $(THREADSLIB) $(LIBDL)
object_unittest_SOURCES = object_unittest.cc
binary_unittest_SOURCES = binary_unittest.cc
@@ -1515,6 +1567,24 @@ many_sections_test$(EXEEXT): $(many_sections_test_OBJECTS) $(many_sections_test_
object_unittest$(EXEEXT): $(object_unittest_OBJECTS) $(object_unittest_DEPENDENCIES)
@rm -f object_unittest$(EXEEXT)
$(CXXLINK) $(object_unittest_LDFLAGS) $(object_unittest_OBJECTS) $(object_unittest_LDADD) $(LIBS)
+@GCC_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES)
+@GCC_FALSE@ @rm -f plugin_test_1$(EXEEXT)
+@GCC_FALSE@ $(LINK) $(plugin_test_1_LDFLAGS) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES)
+@NATIVE_LINKER_FALSE@ @rm -f plugin_test_1$(EXEEXT)
+@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_1_LDFLAGS) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS)
+@PLUGINS_FALSE@plugin_test_1$(EXEEXT): $(plugin_test_1_OBJECTS) $(plugin_test_1_DEPENDENCIES)
+@PLUGINS_FALSE@ @rm -f plugin_test_1$(EXEEXT)
+@PLUGINS_FALSE@ $(LINK) $(plugin_test_1_LDFLAGS) $(plugin_test_1_OBJECTS) $(plugin_test_1_LDADD) $(LIBS)
+@GCC_FALSE@plugin_test_2$(EXEEXT): $(plugin_test_2_OBJECTS) $(plugin_test_2_DEPENDENCIES)
+@GCC_FALSE@ @rm -f plugin_test_2$(EXEEXT)
+@GCC_FALSE@ $(LINK) $(plugin_test_2_LDFLAGS) $(plugin_test_2_OBJECTS) $(plugin_test_2_LDADD) $(LIBS)
+@NATIVE_LINKER_FALSE@plugin_test_2$(EXEEXT): $(plugin_test_2_OBJECTS) $(plugin_test_2_DEPENDENCIES)
+@NATIVE_LINKER_FALSE@ @rm -f plugin_test_2$(EXEEXT)
+@NATIVE_LINKER_FALSE@ $(LINK) $(plugin_test_2_LDFLAGS) $(plugin_test_2_OBJECTS) $(plugin_test_2_LDADD) $(LIBS)
+@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)
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)
@@ -1692,6 +1762,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_r_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_test.Po@am__quote@
@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)/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@
@@ -2313,6 +2385,28 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ basic_test.o -T $(srcdir)/script_test_4.t
@GCC_TRUE@@NATIVE_LINKER_TRUE@script_test_4.stdout: script_test_4
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(TEST_READELF) -SlW script_test_4 > script_test_4.stdout
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms gcctestdir/ld plugin_test.so
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(CXXLINK) -Bgcctestdir/ -Wl,--no-demangle,--plugin,"./plugin_test.so;_Z4f13iv" two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_test_2.syms 2>plugin_test_1.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_1.err: plugin_test_1
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ @touch plugin_test_1.err
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test_2: two_file_test_main.o two_file_test_1.syms two_file_test_1b.syms two_file_shared_2.so gcctestdir/ld plugin_test.so
+@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.so: plugin_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(LINK) -Bgcctestdir/ -shared plugin_test.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@plugin_test.o: plugin_test.c
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(COMPILE) -O0 -c -fpic -o $@ $<
+
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_main.syms: two_file_test_main.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_1.syms: two_file_test_1.o
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ $(TEST_READELF) -sW $< >$@ 2>/dev/null
+@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@two_file_test_1b.syms: two_file_test_1b.o
+@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
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
diff --git a/gold/testsuite/plugin_test.c b/gold/testsuite/plugin_test.c
new file mode 100644
index 0000000..c60c7a1
--- /dev/null
+++ b/gold/testsuite/plugin_test.c
@@ -0,0 +1,427 @@
+/* test_plugin.c -- simple linker plugin test
+
+ Copyright 2008 Free Software Foundation, Inc.
+ Written by Cary Coutant <ccoutant@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. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "plugin-api.h"
+
+struct claimed_file
+{
+ const char* name;
+ void* handle;
+ int nsyms;
+ struct ld_plugin_symbol* syms;
+ struct claimed_file* next;
+};
+
+static struct claimed_file* first_claimed_file = NULL;
+static struct claimed_file* last_claimed_file = NULL;
+
+static ld_plugin_register_claim_file register_claim_file_hook = NULL;
+static ld_plugin_register_all_symbols_read register_all_symbols_read_hook = NULL;
+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_add_input_file add_input_file = NULL;
+static ld_plugin_message message = NULL;
+
+#define MAXOPTS 10
+
+static const char *opts[MAXOPTS];
+static int nopts = 0;
+
+enum ld_plugin_status onload(struct ld_plugin_tv *tv);
+enum ld_plugin_status claim_file_hook(const struct ld_plugin_input_file *file,
+ int *claimed);
+enum ld_plugin_status all_symbols_read_hook(void);
+enum ld_plugin_status cleanup_hook(void);
+
+enum ld_plugin_status
+onload(struct ld_plugin_tv *tv)
+{
+ struct ld_plugin_tv *entry;
+ int api_version = 0;
+ int gold_version = 0;
+ int i;
+
+ for (entry = tv; entry->tv_tag != LDPT_NULL; ++entry)
+ {
+ switch (entry->tv_tag)
+ {
+ case LDPT_API_VERSION:
+ api_version = entry->tv_u.tv_val;
+ break;
+ case LDPT_GOLD_VERSION:
+ gold_version = entry->tv_u.tv_val;
+ break;
+ case LDPT_LINKER_OUTPUT:
+ break;
+ case LDPT_OPTION:
+ if (nopts < MAXOPTS)
+ opts[nopts++] = entry->tv_u.tv_string;
+ break;
+ case LDPT_REGISTER_CLAIM_FILE_HOOK:
+ register_claim_file_hook = entry->tv_u.tv_register_claim_file;
+ break;
+ case LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK:
+ register_all_symbols_read_hook =
+ entry->tv_u.tv_register_all_symbols_read;
+ break;
+ case LDPT_REGISTER_CLEANUP_HOOK:
+ register_cleanup_hook = entry->tv_u.tv_register_cleanup;
+ break;
+ case LDPT_ADD_SYMBOLS:
+ add_symbols = entry->tv_u.tv_add_symbols;
+ break;
+ case LDPT_GET_SYMBOLS:
+ get_symbols = entry->tv_u.tv_get_symbols;
+ break;
+ case LDPT_ADD_INPUT_FILE:
+ add_input_file = entry->tv_u.tv_add_input_file;
+ break;
+ case LDPT_MESSAGE:
+ message = entry->tv_u.tv_message;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (message == NULL)
+ {
+ fprintf(stderr, "tv_message interface missing\n");
+ return LDPS_ERR;
+ }
+
+ if (register_claim_file_hook == NULL)
+ {
+ fprintf(stderr, "tv_register_claim_file_hook interface missing\n");
+ return LDPS_ERR;
+ }
+
+ if (register_all_symbols_read_hook == NULL)
+ {
+ fprintf(stderr, "tv_register_all_symbols_read_hook interface missing\n");
+ return LDPS_ERR;
+ }
+
+ if (register_cleanup_hook == NULL)
+ {
+ fprintf(stderr, "tv_register_cleanup_hook interface missing\n");
+ return LDPS_ERR;
+ }
+
+ (*message)(LDPL_INFO, "API version: %d", api_version);
+ (*message)(LDPL_INFO, "gold version: %d", gold_version);
+
+ for (i = 0; i < nopts; ++i)
+ (*message)(LDPL_INFO, "option: %s", opts[i]);
+
+ if ((*register_claim_file_hook)(claim_file_hook) != LDPS_OK)
+ {
+ (*message)(LDPL_ERROR, "error registering claim file hook");
+ return LDPS_ERR;
+ }
+
+ if ((*register_all_symbols_read_hook)(all_symbols_read_hook) != LDPS_OK)
+ {
+ (*message)(LDPL_ERROR, "error registering all symbols read hook");
+ return LDPS_ERR;
+ }
+
+ if ((*register_cleanup_hook)(cleanup_hook) != LDPS_OK)
+ {
+ (*message)(LDPL_ERROR, "error registering cleanup hook");
+ return LDPS_ERR;
+ }
+
+ return LDPS_OK;
+}
+
+enum ld_plugin_status
+claim_file_hook (const struct ld_plugin_input_file* file, int* claimed)
+{
+ int len;
+ char buf[160];
+ struct claimed_file* claimed_file;
+ struct ld_plugin_symbol* syms;
+ int nsyms = 0;
+ int maxsyms = 0;
+ FILE* irfile;
+ char *p;
+ char *pbind;
+ char *pvis;
+ char *psect;
+ int weak;
+ int def;
+ int vis;
+ int size;
+ char* name;
+ int is_comdat;
+ int i;
+
+ (*message)(LDPL_INFO,
+ "%s: claim file hook called (offset = %ld, size = %ld)",
+ file->name, (long)file->offset, (long)file->filesize);
+
+ /* Look for the beginning of output from readelf -s. */
+ irfile = fdopen(file->fd, "r");
+ (void)fseek(irfile, file->offset, SEEK_SET);
+ len = fread(buf, 1, 13, irfile);
+ if (len < 13 || strncmp(buf, "\nSymbol table", 13) != 0)
+ return LDPS_OK;
+
+ /* Skip the two header lines. */
+ (void) fgets(buf, sizeof(buf), irfile);
+ (void) fgets(buf, sizeof(buf), irfile);
+
+ if (add_symbols == NULL)
+ {
+ fprintf(stderr, "tv_add_symbols interface missing\n");
+ return LDPS_ERR;
+ }
+
+ /* Parse the output from readelf. The columns are:
+ Index Value Size Type Binding Visibility Section Name. */
+ syms = (struct ld_plugin_symbol*)malloc(sizeof(struct ld_plugin_symbol) * 8);
+ if (syms == NULL)
+ return LDPS_ERR;
+ maxsyms = 8;
+ while (fgets(buf, sizeof(buf), irfile) != NULL)
+ {
+ p = buf;
+ p += strspn(p, " ");
+
+ /* Index field. */
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Value field. */
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Size field. */
+ size = atoi(p);
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Type field. */
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Binding field. */
+ pbind = p;
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Visibility field. */
+ pvis = p;
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Section field. */
+ psect = p;
+ p += strcspn(p, " ");
+ p += strspn(p, " ");
+
+ /* Name field. */
+ /* FIXME: Look for version. */
+ len = strlen(p);
+ if (p[len-1] == '\n')
+ p[--len] = '\0';
+ name = malloc(len + 1);
+ strncpy(name, p, len + 1);
+
+ /* Ignore local symbols. */
+ if (strncmp(pbind, "LOCAL", 5) == 0)
+ continue;
+
+ weak = strncmp(pbind, "WEAK", 4) == 0;
+ if (strncmp(psect, "UND", 3) == 0)
+ def = weak ? LDPK_WEAKUNDEF : LDPK_UNDEF;
+ else if (strncmp(psect, "COM", 3) == 0)
+ def = LDPK_COMMON;
+ else
+ def = weak ? LDPK_WEAKDEF : LDPK_DEF;
+
+ if (strncmp(pvis, "INTERNAL", 8) == 0)
+ vis = LDPV_INTERNAL;
+ else if (strncmp(pvis, "HIDDEN", 6) == 0)
+ vis = LDPV_HIDDEN;
+ else if (strncmp(pvis, "PROTECTED", 9) == 0)
+ vis = LDPV_PROTECTED;
+ else
+ vis = LDPV_DEFAULT;
+
+ /* If the symbol is listed in the options list, special-case
+ it as a comdat symbol. */
+ is_comdat = 0;
+ for (i = 0; i < nopts; ++i)
+ {
+ if (name != NULL && strcmp(name, opts[i]) == 0)
+ {
+ is_comdat = 1;
+ break;
+ }
+ }
+
+ if (nsyms >= maxsyms)
+ {
+ syms = (struct ld_plugin_symbol*)
+ realloc(syms, sizeof(struct ld_plugin_symbol) * maxsyms * 2);
+ if (syms == NULL)
+ return LDPS_ERR;
+ maxsyms *= 2;
+ }
+
+ syms[nsyms].name = name;
+ syms[nsyms].version = NULL;
+ syms[nsyms].def = def;
+ syms[nsyms].visibility = vis;
+ syms[nsyms].size = size;
+ syms[nsyms].comdat_key = is_comdat ? name : NULL;
+ syms[nsyms].resolution = LDPR_UNKNOWN;
+ ++nsyms;
+ }
+
+ claimed_file = (struct claimed_file*) malloc(sizeof(struct claimed_file));
+ if (claimed_file == NULL)
+ return LDPS_ERR;
+
+ claimed_file->name = file->name;
+ claimed_file->handle = file->handle;
+ claimed_file->nsyms = nsyms;
+ claimed_file->syms = syms;
+ claimed_file->next = NULL;
+ if (last_claimed_file == NULL)
+ first_claimed_file = claimed_file;
+ else
+ last_claimed_file->next = claimed_file;
+ last_claimed_file = claimed_file;
+
+ (*add_symbols)(file->handle, nsyms, syms);
+
+ *claimed = 1;
+ return LDPS_OK;
+}
+
+enum ld_plugin_status
+all_symbols_read_hook(void)
+{
+ int i;
+ const char* res;
+ struct claimed_file* claimed_file;
+ char buf[160];
+ char *p;
+
+ (*message)(LDPL_INFO, "all symbols read hook called");
+
+ if (get_symbols == NULL)
+ {
+ fprintf(stderr, "tv_get_symbols interface missing\n");
+ return LDPS_ERR;
+ }
+
+ for (claimed_file = first_claimed_file;
+ claimed_file != NULL;
+ claimed_file = claimed_file->next)
+ {
+ (*get_symbols)(claimed_file->handle, claimed_file->nsyms,
+ claimed_file->syms);
+ for (i = 0; i < claimed_file->nsyms; ++i)
+ {
+ switch (claimed_file->syms[i].resolution)
+ {
+ case LDPR_UNKNOWN:
+ res = "UNKNOWN";
+ break;
+ case LDPR_UNDEF:
+ res = "UNDEF";
+ break;
+ case LDPR_PREVAILING_DEF:
+ res = "PREVAILING_DEF_REG";
+ break;
+ case LDPR_PREVAILING_DEF_IRONLY:
+ res = "PREVAILING_DEF_IRONLY";
+ break;
+ case LDPR_PREEMPTED_REG:
+ res = "PREEMPTED_REG";
+ break;
+ case LDPR_PREEMPTED_IR:
+ res = "PREEMPTED_IR";
+ break;
+ case LDPR_RESOLVED_IR:
+ res = "RESOLVED_IR";
+ break;
+ case LDPR_RESOLVED_EXEC:
+ res = "RESOLVED_EXEC";
+ break;
+ case LDPR_RESOLVED_DYN:
+ res = "RESOLVED_DYN";
+ break;
+ default:
+ res = "?";
+ break;
+ }
+ (*message)(LDPL_INFO, "%s: %s: %s", claimed_file->name,
+ claimed_file->syms[i].name, res);
+ }
+ }
+
+ if (add_input_file == NULL)
+ {
+ fprintf(stderr, "tv_add_input_file interface missing\n");
+ return LDPS_ERR;
+ }
+
+ for (claimed_file = first_claimed_file;
+ claimed_file != NULL;
+ claimed_file = claimed_file->next)
+ {
+ if (strlen(claimed_file->name) >= sizeof(buf))
+ {
+ (*message)(LDPL_FATAL, "%s: filename too long", claimed_file->name);
+ return LDPS_ERR;
+ }
+ strcpy(buf, claimed_file->name);
+ p = strrchr(buf, '.');
+ if (p == NULL || strcmp(p, ".syms") != 0)
+ {
+ (*message)(LDPL_FATAL, "%s: filename must have '.syms' suffix",
+ claimed_file->name);
+ return LDPS_ERR;
+ }
+ p[1] = 'o';
+ p[2] = '\0';
+ (*add_input_file)(buf);
+ }
+
+ return LDPS_OK;
+}
+
+enum ld_plugin_status
+cleanup_hook(void)
+{
+ (*message)(LDPL_INFO, "cleanup hook called");
+ return LDPS_OK;
+}
diff --git a/gold/testsuite/plugin_test_1.sh b/gold/testsuite/plugin_test_1.sh
new file mode 100755
index 0000000..5e16139
--- /dev/null
+++ b/gold/testsuite/plugin_test_1.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+# plugin_test_1.sh -- a test case for the plugin API.
+
+# Copyright 2008 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@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_1.err "API version:"
+check plugin_test_1.err "gold version:"
+check plugin_test_1.err "option: _Z4f13iv"
+check plugin_test_1.err "two_file_test_main.o: claim file hook called"
+check plugin_test_1.err "two_file_test_1.syms: claim file hook called"
+check plugin_test_1.err "two_file_test_1b.syms: claim file hook called"
+check plugin_test_1.err "two_file_test_2.syms: claim file hook called"
+check plugin_test_1.err "two_file_test_1.syms: _Z4f13iv: PREVAILING_DEF_IRONLY"
+check plugin_test_1.err "two_file_test_1.syms: _Z2t2v: PREVAILING_DEF_REG"
+check plugin_test_1.err "two_file_test_1.syms: v2: RESOLVED_IR"
+check plugin_test_1.err "two_file_test_1.syms: t17data: RESOLVED_IR"
+check plugin_test_1.err "two_file_test_2.syms: _Z4f13iv: PREEMPTED_IR"
+check plugin_test_1.err "cleanup hook called"
+
+exit 0
diff --git a/gold/testsuite/plugin_test_2.sh b/gold/testsuite/plugin_test_2.sh
new file mode 100755
index 0000000..41865ac
--- /dev/null
+++ b/gold/testsuite/plugin_test_2.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+# plugin_test_2.sh -- a test case for the plugin API.
+
+# Copyright 2008 Free Software Foundation, Inc.
+# Written by Cary Coutant <ccoutant@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_2.err "API version:"
+check plugin_test_2.err "gold version:"
+check plugin_test_2.err "two_file_test_main.o: claim file hook called"
+check plugin_test_2.err "two_file_test_1.syms: claim file hook called"
+check plugin_test_2.err "two_file_test_1b.syms: claim file hook called"
+check plugin_test_2.err "two_file_shared_2.so: claim file hook called"
+check plugin_test_2.err "two_file_test_1.syms: _Z4f13iv: PREVAILING_DEF_REG"
+check plugin_test_2.err "two_file_test_1.syms: _Z2t2v: PREVAILING_DEF_REG"
+check plugin_test_2.err "two_file_test_1.syms: v2: RESOLVED_DYN"
+check plugin_test_2.err "two_file_test_1.syms: t17data: RESOLVED_DYN"
+check plugin_test_2.err "cleanup hook called"
+
+exit 0