This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Add plugin support for bfd


This is an updated patch that adds plugin support to bfd. I posted a
previous version a long time ago, sorry for the delay.

The main reason to include plugin support is for doing (almost)
transparent link time optimization with llvm. With this patch it is
possible to do

$ llvm-gcc -c -emit-llvm a.c
$ llvm-gcc -c -emit-llvm b.c
$ nm b.o
00000000 T f
$ ar q b.a b.o
$ nm b.a
b.o:
00000000 T f
$ llvm-gcc -use-gold-plugin -O2 a.o b.a -o t
$ gdb t
...
(gdb) disassemble main
Dump of assembler code for function main:
0x0000000000400330 <main+0>:    mov    $0x2a,%eax
0x0000000000400335 <main+5>:    retq

Note that nm and ar understand the llvm  bitcode format and that the
function f was extracted from the archive b.a and inlined into main.

The plugin support is implemented with a plugin target that implements
a small set of callbacks. I have tested only nm and ar. It is disable
by default. To enable configure with --enable-plugins (the same option
used by gold).

bfd/
2009-04-28  Rafael Avila de Espindola  <espindola@google.com>

        * Makefile.am (AM_CFLAGS): Add $(LFS_CFLAGS) -DBINDIR='"$(bindir)"'.
	(BFD32_BACKENDS): Add plugin.lo.
	(BFD32_BACKENDS_CFILES): Add plugin.c
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
	* bfd.c (struct bfd): Add plugin_data to tdata.
	(plugin_name): New.
	(bfd_plugin_set_plugin): New.
	(bfd_plugin_get_plugin): New.
	* config.bfd: Handle the plugin target.
	* configure: Regenerate.
	* configure.in: Check for --enable-plugins.
	* doc/Makefile.in: Regenerate.
	* plugin.c: New.
	* plugin.h: New.
	* targets.c (plugin_vec): New.
	(_bfd_target_vector): Add plugin_vec.

binutils/
2009-04-28  Rafael Avila de Espindola  <espindola@google.com>

	* Makefile.am (LIBDL): New.
	(LDADD): Add LIBDL.
	(objdump_LDADD): Add LIBDL.
	(ar_LDADD): Add LIBDL.
	(ranlib_LDADD): Add LIBDL.
	* Makefile.in: Regenerate.
	* ar.c (main): Handle the --plugin option.
	* configure: Regenerate.
	* configure.in: Check for --enable-plugins.
	* doc/Makefile.in: Regenerate.
	* nm.c (OPTION_PLUGIN): New.
	(long_options): Add plugin.
	(main): Handle OPTION_PLUGIN.

gas/
2009-04-28  Rafael Avila de Espindola  <espindola@google.com>

	* Makefile.am (LIBDL): New.
	(as_new_LDADD): Add LIBDL.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.in: Check for --enable-plugins.
	* doc/Makefile.in: Regenerate.

gprof/
2009-04-28  Rafael Avila de Espindola  <espindola@google.com>

	* Makefile.am (LIBDL):New.
	(gprof_LDADD): Add LIBDL.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.in: Check for --enable-plugins.

ld/
2009-04-28  Rafael Avila de Espindola  <espindola@google.com>

	* Makefile.am (LIBDL): New.
	(ld_new_LDADD): New.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* configure.in: Check for --enable-plugins.

Cheers,
Rafael
diff -ruN a/bfd/Makefile.am b/bfd/Makefile.am
--- a/bfd/Makefile.am	2009-04-16 16:39:41.000000000 +0100
+++ b/bfd/Makefile.am	2009-04-28 16:45:07.000000000 +0100
@@ -25,7 +25,7 @@
 
 WARN_CFLAGS = @WARN_CFLAGS@
 NO_WERROR = @NO_WERROR@
-AM_CFLAGS = $(WARN_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -DBINDIR='"$(bindir)"'
 
 # bfd.h goes here, for now
 BFD_H = bfd.h
@@ -358,6 +358,7 @@
 	pe-mips.lo \
 	pei-mips.lo \
 	peigen.lo \
+	plugin.lo \
 	ppcboot.lo \
 	reloc16.lo \
 	riscix.lo \
@@ -540,6 +541,7 @@
 	pei-sh.c \
 	pe-mips.c \
 	pei-mips.c \
+	plugin.c \
 	ppcboot.c \
 	reloc16.c \
 	riscix.c \
diff -ruN a/bfd/Makefile.in b/bfd/Makefile.in
--- a/bfd/Makefile.in	2009-04-16 16:39:41.000000000 +0100
+++ b/bfd/Makefile.in	2009-04-28 16:45:39.000000000 +0100
@@ -167,6 +167,7 @@
 INSTOBJEXT = @INSTOBJEXT@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
+LFS_CFLAGS = @LFS_CFLAGS@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
 LIBM = @LIBM@
@@ -292,7 +293,7 @@
 SUBDIRS = doc po
 bfddocdir = doc
 bfdlib_LTLIBRARIES = libbfd.la
-AM_CFLAGS = $(WARN_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) $(LFS_CFLAGS) -DBINDIR='"$(bindir)"'
 
 # bfd.h goes here, for now
 BFD_H = bfd.h
@@ -625,6 +626,7 @@
 	pe-mips.lo \
 	pei-mips.lo \
 	peigen.lo \
+	plugin.lo \
 	ppcboot.lo \
 	reloc16.lo \
 	riscix.lo \
@@ -807,6 +809,7 @@
 	pei-sh.c \
 	pe-mips.c \
 	pei-mips.c \
+	plugin.c \
 	ppcboot.c \
 	reloc16.c \
 	riscix.c \
diff -ruN a/bfd/bfd-in2.h b/bfd/bfd-in2.h
--- a/bfd/bfd-in2.h	2009-04-16 16:39:41.000000000 +0100
+++ b/bfd/bfd-in2.h	2009-04-28 16:45:07.000000000 +0100
@@ -4875,6 +4875,7 @@
       struct netbsd_core_struct *netbsd_core_data;
       struct mach_o_data_struct *mach_o_data;
       struct mach_o_fat_data_struct *mach_o_fat_data;
+      struct plugin_data_struct *plugin_data;
       struct bfd_pef_data_struct *pef_data;
       struct bfd_pef_xlib_data_struct *pef_xlib_data;
       struct bfd_sym_data_struct *sym_data;
@@ -4946,6 +4947,10 @@
 }
 bfd_error_type;
 
+void bfd_plugin_set_plugin (const char *p);
+
+const char * bfd_plugin_get_plugin (void);
+
 bfd_error_type bfd_get_error (void);
 
 void bfd_set_error (bfd_error_type error_tag, ...);
diff -ruN a/bfd/bfd.c b/bfd/bfd.c
--- a/bfd/bfd.c	2009-03-11 04:36:39.000000000 +0000
+++ b/bfd/bfd.c	2009-04-28 17:07:23.000000000 +0100
@@ -240,6 +240,7 @@
 .      struct netbsd_core_struct *netbsd_core_data;
 .      struct mach_o_data_struct *mach_o_data;
 .      struct mach_o_fat_data_struct *mach_o_fat_data;
+.      struct plugin_data_struct *plugin_data;
 .      struct bfd_pef_data_struct *pef_data;
 .      struct bfd_pef_xlib_data_struct *pef_xlib_data;
 .      struct bfd_sym_data_struct *sym_data;
@@ -393,6 +394,42 @@
   N_("#<Invalid error code>")
 };
 
+static const char *plugin_name;
+
+/*
+FUNCTION
+	bfd_plugin_set_plugin
+
+SYNOPSIS
+	void bfd_plugin_set_plugin (const char *p);
+
+DESCRIPTION
+	Set the plugin file.
+*/
+
+void
+bfd_plugin_set_plugin (const char *p)
+{
+  plugin_name = p;
+}
+
+/*
+FUNCTION
+	bfd_plugin_get_plugin
+
+SYNOPSIS
+	const char * bfd_plugin_get_plugin (void);
+
+DESCRIPTION
+	Get the plugin file.
+*/
+
+const char *
+bfd_plugin_get_plugin (void)
+{
+  return plugin_name;
+}
+
 /*
 FUNCTION
 	bfd_get_error
diff -ruN a/bfd/config.bfd b/bfd/config.bfd
--- a/bfd/config.bfd	2009-04-16 16:39:41.000000000 +0100
+++ b/bfd/config.bfd	2009-04-28 16:45:07.000000000 +0100
@@ -137,6 +137,12 @@
     exit 1
     ;;
 
+  plugin)
+    targ_defvec=plugin_vec
+    targ_selvecs="plugin_vec"
+    targ_archs="bfd_i386_arch"
+    ;;
+
 # START OF targmatch.h
 #ifdef BFD64
   alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu)
diff -ruN a/bfd/configure b/bfd/configure
--- a/bfd/configure	2009-04-16 16:39:42.000000000 +0100
+++ b/bfd/configure	2009-04-28 16:45:07.000000000 +0100
@@ -458,7 +458,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE AR ac_ct_AR RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 DEBUGDIR PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI WARN_CFLAGS NO_WERROR MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE INSTALL_LIBBFD_TRUE INSTALL_LIBBFD_FALSE host_noncanonical target_noncanonical bfdlibdir bfdincludedir USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE HDEFINES BFD_HOST_64BIT_LONG BFD_HOST_64BIT_LONG_LONG BFD_HOST_64_BIT_DEFINED BFD_HOST_64_BIT BFD_HOST_U_64_BIT BFD_HOSTPTR_T CC_FOR_BUILD EXEEXT_FOR_BUILD COREFILE COREFLAG LIBM SHARED_LDFLAGS SHARED_LIBADD TDEFINES wordsize bfd64_libs all_backends bfd_backends bfd_machines bfd_default_target_size bfd_file_ptr bfd_ufile_ptr tdefaults datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE AR ac_ct_AR RANLIB ac_ct_RANLIB CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 DEBUGDIR PKGVERSION REPORT_BUGS_TO REPORT_BUGS_TEXI WARN_CFLAGS NO_WERROR MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE INSTALL_LIBBFD_TRUE INSTALL_LIBBFD_FALSE host_noncanonical target_noncanonical bfdlibdir bfdincludedir USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE HDEFINES LFS_CFLAGS BFD_HOST_64BIT_LONG BFD_HOST_64BIT_LONG_LONG BFD_HOST_64_BIT_DEFINED BFD_HOST_64_BIT BFD_HOST_U_64_BIT BFD_HOSTPTR_T CC_FOR_BUILD EXEEXT_FOR_BUILD COREFILE COREFLAG LIBM SHARED_LDFLAGS SHARED_LIBADD TDEFINES wordsize bfd64_libs all_backends bfd_backends bfd_machines bfd_default_target_size bfd_file_ptr bfd_ufile_ptr tdefaults datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 ac_pwd=`pwd`
 
@@ -1020,6 +1020,7 @@
 			  (and sometimes confusing) to the casual installer
   --enable-install-libbfd controls installation of libbfd and related headers
   --disable-nls           do not use Native Language Support
+  --enable-plugins        linker plugins
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -5719,13 +5720,13 @@
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5722: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:5723: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5725: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:5726: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5728: output\"" >&5)
+  (eval echo "\"\$as_me:5729: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6882,7 +6883,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6885 "configure"' > conftest.$ac_ext
+  echo '#line 6886 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -8158,11 +8159,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8161: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8162: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8165: \$? = $ac_status" >&5
+   echo "$as_me:8166: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8497,11 +8498,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8500: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8501: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8504: \$? = $ac_status" >&5
+   echo "$as_me:8505: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8602,11 +8603,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8605: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8606: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8609: \$? = $ac_status" >&5
+   echo "$as_me:8610: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8657,11 +8658,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8660: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8661: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8664: \$? = $ac_status" >&5
+   echo "$as_me:8665: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11469,7 +11470,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11472 "configure"
+#line 11473 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11565,7 +11566,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11568 "configure"
+#line 11569 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12494,6 +12495,10 @@
 . ${srcdir}/configure.host
 
 
+
+LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+
+
 # Find a good install program.  We prefer a C program (faster),
 # so one script is as good as another.  But avoid the broken or
 # incompatible versions:
@@ -20825,6 +20830,22 @@
 
 # target stuff:
 
+# Check whether --enable-plugins or --disable-plugins was given.
+if test "${enable_plugins+set}" = set; then
+  enableval="$enable_plugins"
+  case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac
+else
+  plugins=no
+fi;
+
+if test "$plugins" = "yes"; then
+  enable_targets="$enable_targets plugin";
+fi
+
 # Canonicalize the secondary target names.
 if test -n "$enable_targets" ; then
     for targ in `echo $enable_targets | sed 's/,/ /g'`
@@ -21158,6 +21179,7 @@
     pef_vec)                    tb="$tb pef.lo" ;;
     pef_xlib_vec)               tb="$tb pef.lo" ;;
     pdp11_aout_vec)		tb="$tb pdp11.lo" ;;
+    plugin_vec)                 tb="$tb plugin.lo" ;;
     pmac_xcoff_vec)		tb="$tb coff-rs6000.lo xcofflink.lo" ;;
     ppcboot_vec)		tb="$tb ppcboot.lo" ;;
     riscix_vec)			tb="$tb aout32.lo riscix.lo" ;;
@@ -23491,6 +23513,7 @@
 s,@MSGFMT@,$MSGFMT,;t t
 s,@MSGMERGE@,$MSGMERGE,;t t
 s,@HDEFINES@,$HDEFINES,;t t
+s,@LFS_CFLAGS@,$LFS_CFLAGS,;t t
 s,@BFD_HOST_64BIT_LONG@,$BFD_HOST_64BIT_LONG,;t t
 s,@BFD_HOST_64BIT_LONG_LONG@,$BFD_HOST_64BIT_LONG_LONG,;t t
 s,@BFD_HOST_64_BIT_DEFINED@,$BFD_HOST_64_BIT_DEFINED,;t t
diff -ruN a/bfd/configure.in b/bfd/configure.in
--- a/bfd/configure.in	2009-04-16 16:39:42.000000000 +0100
+++ b/bfd/configure.in	2009-04-28 16:45:07.000000000 +0100
@@ -137,6 +137,12 @@
 . ${srcdir}/configure.host
 
 AC_SUBST(HDEFINES)
+
+dnl Force support for large files by default.  This may need to be
+dnl host dependent.  If build == host, we can check getconf LFS_CFLAGS.
+LFS_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+AC_SUBST(LFS_CFLAGS)
+
 AC_PROG_INSTALL
 
 BFD_HOST_64BIT_LONG=0
@@ -546,6 +552,19 @@
 
 # target stuff:
 
+AC_ARG_ENABLE([plugins],
+[  --enable-plugins        linker plugins],
+[case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac],
+[plugins=no])
+
+if test "$plugins" = "yes"; then
+  enable_targets="$enable_targets plugin";
+fi
+
 # Canonicalize the secondary target names.
 if test -n "$enable_targets" ; then
     for targ in `echo $enable_targets | sed 's/,/ /g'`
@@ -879,6 +898,7 @@
     pef_vec)                    tb="$tb pef.lo" ;;
     pef_xlib_vec)               tb="$tb pef.lo" ;;
     pdp11_aout_vec)		tb="$tb pdp11.lo" ;;
+    plugin_vec)                 tb="$tb plugin.lo" ;;
     pmac_xcoff_vec)		tb="$tb coff-rs6000.lo xcofflink.lo" ;;
     ppcboot_vec)		tb="$tb ppcboot.lo" ;;
     riscix_vec)			tb="$tb aout32.lo riscix.lo" ;;
diff -ruN a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
--- a/bfd/doc/Makefile.in	2009-02-03 15:53:59.000000000 +0000
+++ b/bfd/doc/Makefile.in	2009-04-28 16:45:39.000000000 +0100
@@ -140,8 +140,10 @@
 INSTOBJEXT = @INSTOBJEXT@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
+LFS_CFLAGS = @LFS_CFLAGS@
 LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
+LIBM = @LIBM@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
diff -ruN a/bfd/plugin.c b/bfd/plugin.c
--- a/bfd/plugin.c	1970-01-01 01:00:00.000000000 +0100
+++ b/bfd/plugin.c	2009-04-28 16:45:20.000000000 +0100
@@ -0,0 +1,476 @@
+/* Plugin support for BFD.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008
+   Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   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 <assert.h>
+#include <dlfcn.h>
+#include <stdarg.h>
+#include "plugin-api.h"
+#include "sysdep.h"
+#include "plugin.h"
+#include "libbfd.h"
+#include "libiberty.h"
+#include <dirent.h>
+
+#define bfd_plugin_close_and_cleanup                  _bfd_generic_close_and_cleanup
+#define bfd_plugin_bfd_free_cached_info               _bfd_generic_bfd_free_cached_info
+#define bfd_plugin_new_section_hook                   _bfd_generic_new_section_hook
+#define bfd_plugin_get_section_contents               _bfd_generic_get_section_contents
+#define bfd_plugin_get_section_contents_in_window     _bfd_generic_get_section_contents_in_window
+#define bfd_plugin_bfd_copy_private_header_data       _bfd_generic_bfd_copy_private_header_data
+#define bfd_plugin_bfd_merge_private_bfd_data         _bfd_generic_bfd_merge_private_bfd_data
+#define bfd_plugin_bfd_copy_private_header_data       _bfd_generic_bfd_copy_private_header_data
+#define bfd_plugin_bfd_set_private_flags              _bfd_generic_bfd_set_private_flags
+#define bfd_plugin_core_file_matches_executable_p     generic_core_file_matches_executable_p
+#define bfd_plugin_bfd_is_local_label_name            _bfd_nosymbols_bfd_is_local_label_name
+#define bfd_plugin_bfd_is_target_special_symbol       ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
+#define bfd_plugin_get_lineno                         _bfd_nosymbols_get_lineno
+#define bfd_plugin_find_nearest_line                  _bfd_nosymbols_find_nearest_line
+#define bfd_plugin_find_inliner_info                  _bfd_nosymbols_find_inliner_info
+#define bfd_plugin_bfd_make_debug_symbol              _bfd_nosymbols_bfd_make_debug_symbol
+#define bfd_plugin_read_minisymbols                   _bfd_generic_read_minisymbols
+#define bfd_plugin_minisymbol_to_symbol               _bfd_generic_minisymbol_to_symbol
+#define bfd_plugin_set_arch_mach                      bfd_default_set_arch_mach
+#define bfd_plugin_set_section_contents               _bfd_generic_set_section_contents
+#define bfd_plugin_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
+#define bfd_plugin_bfd_relax_section                  bfd_generic_relax_section
+#define bfd_plugin_bfd_link_hash_table_create         _bfd_generic_link_hash_table_create
+#define bfd_plugin_bfd_link_hash_table_free           _bfd_generic_link_hash_table_free
+#define bfd_plugin_bfd_link_add_symbols               _bfd_generic_link_add_symbols
+#define bfd_plugin_bfd_link_just_syms                 _bfd_generic_link_just_syms
+#define bfd_plugin_bfd_final_link                     _bfd_generic_final_link
+#define bfd_plugin_bfd_link_split_section             _bfd_generic_link_split_section
+#define bfd_plugin_bfd_gc_sections                    bfd_generic_gc_sections
+#define bfd_plugin_bfd_merge_sections                 bfd_generic_merge_sections
+#define bfd_plugin_bfd_is_group_section               bfd_generic_is_group_section
+#define bfd_plugin_bfd_discard_group                  bfd_generic_discard_group
+#define bfd_plugin_section_already_linked             _bfd_generic_section_already_linked
+#define bfd_plugin_bfd_define_common_symbol           bfd_generic_define_common_symbol
+
+static enum ld_plugin_status
+message (int level ATTRIBUTE_UNUSED,
+	 const char * format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  vprintf (format, args);
+  va_end (args);
+  return LDPS_OK;
+}
+
+// Register a claim-file handler.
+static ld_plugin_claim_file_handler claim_file;
+
+static enum ld_plugin_status
+register_claim_file (ld_plugin_claim_file_handler handler)
+{
+  claim_file = handler;
+  return LDPS_OK;
+}
+
+static enum ld_plugin_status
+add_symbols (void* handle, int nsyms,
+	     const struct ld_plugin_symbol *syms)
+{
+  bfd *abfd = handle;
+  struct plugin_data_struct *plugin_data =
+    bfd_alloc (abfd, sizeof (plugin_data_struct));;
+
+  plugin_data->nsyms = nsyms;
+  plugin_data->syms = syms;
+
+  if (nsyms != 0)
+    abfd->flags |= HAS_SYMS;
+
+  abfd->tdata.plugin_data = plugin_data;
+  return LDPS_OK;
+}
+
+extern char *program_name __attribute__ ((weak));
+
+static int
+try_load_plugin (const char *pname)
+{
+  static void *plugin_handle;
+  int tv_size = 4;
+  struct ld_plugin_tv tv[tv_size];
+  int i;
+  ld_plugin_onload onload;
+  enum ld_plugin_status status;
+
+  plugin_handle = dlopen (pname, RTLD_NOW);
+  if (!plugin_handle)
+    {
+      fprintf (stderr, "%s\n", dlerror());
+      return 0;
+    }
+
+  onload = dlsym (plugin_handle, "onload");
+  if (!onload)
+    goto err;
+
+  i = 0;
+  tv[i].tv_tag = LDPT_MESSAGE;
+  tv[i].tv_u.tv_message = message;
+
+  ++i;
+  tv[i].tv_tag = LDPT_REGISTER_CLAIM_FILE_HOOK;
+  tv[i].tv_u.tv_register_claim_file = register_claim_file;
+
+  ++i;
+  tv[i].tv_tag = LDPT_ADD_SYMBOLS;
+  tv[i].tv_u.tv_add_symbols = add_symbols;
+
+  ++i;
+  tv[i].tv_tag = LDPT_NULL;
+  tv[i].tv_u.tv_val = 0;
+
+  status = (*onload)(tv);
+
+  if (status != LDPS_OK)
+    goto err;
+
+  if (!claim_file)
+    goto err;
+
+  return 1;
+
+ err:
+  plugin_handle = NULL;
+  return 0;
+}
+
+static int
+load_plugin (void)
+{
+  char *plugin_dir;
+  char *p;
+  DIR *d;
+  struct dirent *ent;
+  int found = 0;
+  const char *pname = bfd_plugin_get_plugin ();
+
+  if (pname)
+    return try_load_plugin (pname);
+
+  plugin_dir = concat (BINDIR, "/../lib/bfd-plugins", NULL);
+  p = make_relative_prefix (program_name,
+			    BINDIR,
+			    plugin_dir);
+  free (plugin_dir);
+  plugin_dir = NULL;
+
+  d = opendir (p);
+  if (!d)
+    goto out;
+
+  while ((ent = readdir (d)))
+    {
+      char *full_name;
+      if (ent->d_type != DT_REG && ent->d_type != DT_LNK)
+	continue;
+
+      full_name = concat (p, "/", ent->d_name, NULL);
+      found = try_load_plugin (full_name);
+      free (full_name);
+      if (found)
+	break;
+    }
+
+ out:
+  free (p);
+  if (d)
+    closedir (d);
+
+  return found;
+}
+
+
+static const bfd_target *
+bfd_plugin_object_p (bfd *abfd)
+{
+  int claimed = 0;
+  int t = load_plugin ();
+  struct ld_plugin_input_file file;
+  if (!t)
+    return NULL;
+
+  file.name = abfd->filename;
+
+  if (abfd->iostream)
+    {
+      file.fd = fileno (abfd->iostream);
+      file.offset = 0;
+      file.filesize = 0; /*FIXME*/
+    }
+  else
+    {
+      bfd *archive = abfd->my_archive;
+      BFD_ASSERT (archive);
+      file.fd = fileno (archive->iostream);
+      file.offset = abfd->origin;
+      file.filesize = arelt_size (abfd);
+
+    }
+  file.handle = abfd;
+  claim_file (&file, &claimed);
+  if (!claimed)
+    return NULL;
+
+  return abfd->xvec;
+}
+
+/* Copy any private info we understand from the input bfd
+   to the output bfd.  */
+
+static bfd_boolean
+bfd_plugin_bfd_copy_private_bfd_data (bfd *ibfd ATTRIBUTE_UNUSED,
+				      bfd *obfd ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return TRUE;
+}
+
+/* Copy any private info we understand from the input section
+   to the output section.  */
+
+static bfd_boolean
+bfd_plugin_bfd_copy_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED,
+					  asection *isection ATTRIBUTE_UNUSED,
+					  bfd *obfd ATTRIBUTE_UNUSED,
+					  asection *osection ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return TRUE;
+}
+
+/* Copy any private info we understand from the input symbol
+   to the output symbol.  */
+
+static bfd_boolean
+bfd_plugin_bfd_copy_private_symbol_data (bfd *ibfd ATTRIBUTE_UNUSED,
+					 asymbol *isymbol ATTRIBUTE_UNUSED,
+					 bfd *obfd ATTRIBUTE_UNUSED,
+					 asymbol *osymbol ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return TRUE;
+}
+
+static bfd_boolean
+bfd_plugin_bfd_print_private_bfd_data (bfd *abfd ATTRIBUTE_UNUSED, PTR ptr ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return TRUE;
+}
+
+static char *
+bfd_plugin_core_file_failing_command (bfd *abfd ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return NULL;
+}
+
+static int
+bfd_plugin_core_file_failing_signal (bfd *abfd ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return 0;
+}
+
+static long
+bfd_plugin_get_symtab_upper_bound (bfd *abfd)
+{
+  struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+  long nsyms = plugin_data->nsyms;
+
+  BFD_ASSERT (nsyms >= 0);
+
+  return ((nsyms + 1) * sizeof (asymbol *));
+}
+
+static flagword
+convert_flags (const struct ld_plugin_symbol *sym)
+{
+ switch (sym->def)
+   { 
+   case LDPK_DEF:
+   case LDPK_COMMON:
+   case LDPK_UNDEF:
+     return BSF_GLOBAL;
+
+   case LDPK_WEAKUNDEF:
+   case LDPK_WEAKDEF:
+     return BSF_GLOBAL | BSF_WEAK;
+
+   default:
+     BFD_ASSERT (0);
+     return 0;
+   }
+}
+
+static long
+bfd_plugin_canonicalize_symtab (bfd *abfd,
+				asymbol **alocation)
+{
+  struct plugin_data_struct *plugin_data = abfd->tdata.plugin_data;
+  long nsyms = plugin_data->nsyms;
+  const struct ld_plugin_symbol *syms = plugin_data->syms;
+  static asection fake_section;
+  static asection fake_common_section;
+  int i;
+
+  fake_section.name = ".text";
+  fake_common_section.flags = SEC_IS_COMMON;
+
+  for (i = 0; i < nsyms; i++)
+    {
+      asymbol *s = bfd_alloc (abfd, sizeof (asymbol)); 
+
+      BFD_ASSERT (s);
+      alocation[i] = s;
+
+      s->the_bfd = abfd;
+      s->name = syms[i].name;
+      s->value = 0;
+      s->flags = convert_flags (&syms[i]);
+      switch (syms[i].def)
+	{
+	case LDPK_COMMON:
+	  s->section = &fake_common_section;
+	  break;
+	case LDPK_UNDEF:
+	case LDPK_WEAKUNDEF:
+	  s->section = bfd_und_section_ptr;
+	  break;
+	case LDPK_DEF:
+	case LDPK_WEAKDEF:
+	  s->section = &fake_section;
+	  break;
+	default:
+	  BFD_ASSERT (0);
+	}
+
+      s->udata.p = (void *) &syms[i];
+    }
+
+  return nsyms;
+}
+
+static void
+bfd_plugin_print_symbol (bfd *abfd ATTRIBUTE_UNUSED,
+			 PTR afile ATTRIBUTE_UNUSED,
+			 asymbol *symbol ATTRIBUTE_UNUSED,
+			 bfd_print_symbol_type how ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+}
+
+static void
+bfd_plugin_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
+			    asymbol *symbol,
+			    symbol_info *ret)
+{
+  bfd_symbol_info (symbol, ret);
+}
+
+/* Make an empty symbol. */
+
+static asymbol *
+bfd_plugin_make_empty_symbol (bfd *abfd)
+{
+  asymbol *new = bfd_zalloc (abfd, sizeof (asymbol));
+  if (new == NULL)
+    return new;
+  new->the_bfd = abfd;
+  return new;
+}
+
+static int
+bfd_plugin_sizeof_headers (bfd *a ATTRIBUTE_UNUSED,
+			   struct bfd_link_info *info ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return 0;
+}
+
+static bfd_boolean
+bfd_plugin_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
+{
+  BFD_ASSERT (0);
+  return 0;
+}
+
+const bfd_target plugin_vec =
+{
+  "plugin",		/* Name.  */
+  bfd_target_unknown_flavour,
+  BFD_ENDIAN_LITTLE,		/* Target byte order.  */
+  BFD_ENDIAN_LITTLE,		/* Target headers byte order.  */
+  (HAS_RELOC | EXEC_P |		/* Object flags.  */
+   HAS_LINENO | HAS_DEBUG |
+   HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
+  (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
+   | SEC_ALLOC | SEC_LOAD | SEC_RELOC),	/* Section flags.  */
+  0,				/* symbol_leading_char.  */
+  '/',				/* ar_pad_char.  */
+  15,				/* ar_max_namelen.  */
+
+  bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+  bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+  bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* data */
+  bfd_getl64, bfd_getl_signed_64, bfd_putl64,
+  bfd_getl32, bfd_getl_signed_32, bfd_putl32,
+  bfd_getl16, bfd_getl_signed_16, bfd_putl16,	/* hdrs */
+
+  {				/* bfd_check_format.  */
+    _bfd_dummy_target,
+    bfd_plugin_object_p,
+    bfd_generic_archive_p,
+    _bfd_dummy_target
+  },
+  {				/* bfd_set_format.  */
+    bfd_false,
+    bfd_plugin_mkobject,
+    _bfd_generic_mkarchive,
+    bfd_false,
+  },
+  {				/* bfd_write_contents.  */
+    bfd_false,
+    bfd_false,
+    _bfd_write_archive_contents,
+    bfd_false,
+  },
+
+  BFD_JUMP_TABLE_GENERIC (bfd_plugin),
+  BFD_JUMP_TABLE_COPY (bfd_plugin),
+  BFD_JUMP_TABLE_CORE (bfd_plugin),
+  BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
+  BFD_JUMP_TABLE_SYMBOLS (bfd_plugin),
+  BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
+  BFD_JUMP_TABLE_WRITE (bfd_plugin),
+  BFD_JUMP_TABLE_LINK (bfd_plugin),
+  BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
+
+  NULL,
+
+  /* backend_data: */
+  NULL
+};
diff -ruN a/bfd/plugin.h b/bfd/plugin.h
--- a/bfd/plugin.h	1970-01-01 01:00:00.000000000 +0100
+++ b/bfd/plugin.h	2009-04-28 16:45:23.000000000 +0100
@@ -0,0 +1,34 @@
+/* Plugin support for BFD.
+   Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008
+   Free Software Foundation, Inc.
+
+   This file is part of BFD, the Binary File Descriptor library.
+
+   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.  */
+
+#ifndef _PLUGIN_H_
+#define _PLUGIN_H_
+
+#include "bfd.h"
+
+typedef struct plugin_data_struct
+{
+  int nsyms;
+  const struct ld_plugin_symbol *syms;
+}
+plugin_data_struct;
+
+#endif
diff -ruN a/bfd/targets.c b/bfd/targets.c
--- a/bfd/targets.c	2009-04-16 16:39:42.000000000 +0100
+++ b/bfd/targets.c	2009-04-28 16:45:07.000000000 +0100
@@ -768,6 +768,7 @@
 extern const bfd_target pdp11_aout_vec;
 extern const bfd_target pef_vec;
 extern const bfd_target pef_xlib_vec;
+extern const bfd_target plugin_vec;
 extern const bfd_target pmac_xcoff_vec;
 extern const bfd_target ppcboot_vec;
 extern const bfd_target riscix_vec;
@@ -1153,6 +1154,7 @@
 	&pdp11_aout_vec,
 	&pef_vec,
 	&pef_xlib_vec,
+	&plugin_vec,
 #if 0
 	/* This has the same magic number as RS/6000.  */
 	&pmac_xcoff_vec,
diff -ruN a/binutils/Makefile.am b/binutils/Makefile.am
--- a/binutils/Makefile.am	2009-03-18 11:27:17.000000000 +0000
+++ b/binutils/Makefile.am	2009-04-28 16:45:07.000000000 +0100
@@ -22,6 +22,10 @@
 AM_CFLAGS = $(WARN_CFLAGS)
 LIBICONV = @LIBICONV@
 
+if PLUGINS
+LIBDL = -ldl
+endif
+
 # these two are almost the same program
 AR_PROG=ar
 RANLIB_PROG=ranlib
@@ -235,7 +239,7 @@
 readelf_DEPENDENCIES =   $(LIBINTL_DEP) $(LIBIBERTY)
 dllwrap_DEPENDENCIES =   $(LIBINTL_DEP) $(LIBIBERTY)
 
-LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDL)
 
 size_SOURCES = size.c $(BULIBS)
 
@@ -251,7 +255,7 @@
 nm_new_SOURCES = nm.c $(BULIBS)
 
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS)
-objdump_LDADD = $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+objdump_LDADD = $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDL)
 
 objdump.o:objdump.c
 	$(COMPILE) -c $(OBJDUMP_DEFS) $(srcdir)/objdump.c
@@ -260,11 +264,11 @@
 
 ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \
 	emul_$(EMULATION).c $(BULIBS)
-ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL)
+ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL) $(LIBDL)
 
 ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \
 	binemul.c emul_$(EMULATION).c $(BULIBS)
-ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL)
+ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL) $(LIBDL)
 
 addr2line_SOURCES = addr2line.c $(BULIBS)
 
diff -ruN a/binutils/Makefile.in b/binutils/Makefile.in
--- a/binutils/Makefile.in	2009-03-18 11:27:17.000000000 +0000
+++ b/binutils/Makefile.in	2009-04-28 16:45:07.000000000 +0100
@@ -303,6 +303,8 @@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -375,6 +377,7 @@
 tooldir = $(exec_prefix)/$(target_alias)
 YFLAGS = -d
 AM_CFLAGS = $(WARN_CFLAGS)
+@PLUGINS_TRUE@LIBDL = -ldl
 
 # these two are almost the same program
 AR_PROG = ar
@@ -490,7 +493,7 @@
 addr2line_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY) $(BFDLIB)
 readelf_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
 dllwrap_DEPENDENCIES = $(LIBINTL_DEP) $(LIBIBERTY)
-LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+LDADD = $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDL)
 size_SOURCES = size.c $(BULIBS)
 objcopy_SOURCES = objcopy.c not-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 strings_SOURCES = strings.c $(BULIBS)
@@ -499,16 +502,16 @@
 strip_new_SOURCES = objcopy.c is-strip.c rename.c $(WRITE_DEBUG_SRCS) $(BULIBS)
 nm_new_SOURCES = nm.c $(BULIBS)
 objdump_SOURCES = objdump.c dwarf.c prdbg.c $(DEBUG_SRCS) $(BULIBS)
-objdump_LDADD = $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+objdump_LDADD = $(OPCODES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDL)
 cxxfilt_SOURCES = cxxfilt.c $(BULIBS)
 ar_SOURCES = arparse.y arlex.l ar.c not-ranlib.c arsup.c rename.c binemul.c \
 	emul_$(EMULATION).c $(BULIBS)
 
-ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL)
+ar_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL) $(LIBDL)
 ranlib_SOURCES = ar.c is-ranlib.c arparse.y arlex.l arsup.c rename.c \
 	binemul.c emul_$(EMULATION).c $(BULIBS)
 
-ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL)
+ranlib_LDADD = $(BFDLIB) $(LIBIBERTY) @LEXLIB@ $(LIBINTL) $(LIBDL)
 addr2line_SOURCES = addr2line.c $(BULIBS)
 srconv_SOURCES = srconv.c coffgrok.c $(BULIBS)
 dlltool_SOURCES = dlltool.c defparse.y deflex.l $(BULIBS)
diff -ruN a/binutils/ar.c b/binutils/ar.c
--- a/binutils/ar.c	2009-03-11 04:36:39.000000000 +0000
+++ b/binutils/ar.c	2009-04-28 17:08:03.000000000 +0100
@@ -480,6 +480,17 @@
   arg_index = 1;
   arg_ptr = argv[arg_index];
 
+  if (strcmp (arg_ptr, "--plugin") == 0)
+    {
+      if (argc < 4)
+	usage(1);
+
+      bfd_plugin_set_plugin(argv[2]);
+
+      arg_index += 2;
+      arg_ptr = argv[arg_index];
+    }
+
   if (*arg_ptr == '-')
     {
       /* When the first option starts with '-' we support POSIX-compatible
diff -ruN a/binutils/configure b/binutils/configure
--- a/binutils/configure	2009-03-31 09:08:33.000000000 +0100
+++ b/binutils/configure	2009-04-28 16:45:07.000000000 +0100
@@ -458,7 +458,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 WARN_CFLAGS NO_WERROR YACC LEX LEXLIB LEX_OUTPUT_ROOT USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE HDEFINES CC_FOR_BUILD EXEEXT_FOR_BUILD DEMANGLER_NAME ALLOCA LIBICONV LTLIBICONV NLMCONV_DEFS BUILD_NLMCONV BUILD_SRCONV BUILD_DLLTOOL DLLTOOL_DEFS BUILD_WINDRES BUILD_WINDMC BUILD_DLLWRAP BUILD_MISC BUILD_INSTALL_MISC OBJDUMP_DEFS EMULATION EMULATION_VECTOR datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 WARN_CFLAGS NO_WERROR YACC LEX LEXLIB LEX_OUTPUT_ROOT USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE PLUGINS_TRUE PLUGINS_FALSE HDEFINES CC_FOR_BUILD EXEEXT_FOR_BUILD DEMANGLER_NAME ALLOCA LIBICONV LTLIBICONV NLMCONV_DEFS BUILD_NLMCONV BUILD_SRCONV BUILD_DLLTOOL DLLTOOL_DEFS BUILD_WINDRES BUILD_WINDMC BUILD_DLLWRAP BUILD_MISC BUILD_INSTALL_MISC OBJDUMP_DEFS EMULATION EMULATION_VECTOR datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 ac_pwd=`pwd`
 
@@ -1016,6 +1016,7 @@
   --disable-nls           do not use Native Language Support
   --enable-maintainer-mode  enable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
+  --enable-plugins        linker plugins
   --disable-rpath         do not hardcode runtime library paths
 
 Optional Packages:
@@ -5518,13 +5519,13 @@
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5521: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:5522: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5524: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:5525: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5527: output\"" >&5)
+  (eval echo "\"\$as_me:5528: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6681,7 +6682,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6684 "configure"' > conftest.$ac_ext
+  echo '#line 6685 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7987,11 +7988,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7990: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7991: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7994: \$? = $ac_status" >&5
+   echo "$as_me:7995: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8326,11 +8327,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8329: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8330: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8333: \$? = $ac_status" >&5
+   echo "$as_me:8334: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8431,11 +8432,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8434: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8435: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8438: \$? = $ac_status" >&5
+   echo "$as_me:8439: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8486,11 +8487,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8489: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8490: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8493: \$? = $ac_status" >&5
+   echo "$as_me:8494: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11298,7 +11299,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11301 "configure"
+#line 11302 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11394,7 +11395,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11397 "configure"
+#line 11398 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12446,6 +12447,29 @@
   GENINSRC_NEVER_FALSE=
 fi
 
+# Check whether --enable-plugins or --disable-plugins was given.
+if test "${enable_plugins+set}" = set; then
+  enableval="$enable_plugins"
+  case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac
+else
+  plugins=no
+fi;
+
+
+
+if test "$plugins" = "yes"; then
+  PLUGINS_TRUE=
+  PLUGINS_FALSE='#'
+else
+  PLUGINS_TRUE='#'
+  PLUGINS_FALSE=
+fi
+
+
 
 if test -n "$EXEEXT"; then
 
@@ -16419,6 +16443,13 @@
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
@@ -17321,6 +17352,8 @@
 s,@MAINT@,$MAINT,;t t
 s,@GENINSRC_NEVER_TRUE@,$GENINSRC_NEVER_TRUE,;t t
 s,@GENINSRC_NEVER_FALSE@,$GENINSRC_NEVER_FALSE,;t t
+s,@PLUGINS_TRUE@,$PLUGINS_TRUE,;t t
+s,@PLUGINS_FALSE@,$PLUGINS_FALSE,;t t
 s,@HDEFINES@,$HDEFINES,;t t
 s,@CC_FOR_BUILD@,$CC_FOR_BUILD,;t t
 s,@EXEEXT_FOR_BUILD@,$EXEEXT_FOR_BUILD,;t t
diff -ruN a/binutils/configure.in b/binutils/configure.in
--- a/binutils/configure.in	2009-03-31 09:08:33.000000000 +0100
+++ b/binutils/configure.in	2009-04-28 16:45:07.000000000 +0100
@@ -62,6 +62,17 @@
 
 AM_MAINTAINER_MODE
 AM_CONDITIONAL(GENINSRC_NEVER, false)
+AC_ARG_ENABLE([plugins],
+[  --enable-plugins        linker plugins],
+[case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac],
+[plugins=no])
+
+AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
+
 AC_EXEEXT
 if test -n "$EXEEXT"; then
   AC_DEFINE(HAVE_EXECUTABLE_SUFFIX, 1,
diff -ruN a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
--- a/binutils/doc/Makefile.in	2009-02-03 15:54:00.000000000 +0000
+++ b/binutils/doc/Makefile.in	2009-04-28 16:45:07.000000000 +0100
@@ -174,6 +174,8 @@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
diff -ruN a/binutils/nm.c b/binutils/nm.c
--- a/binutils/nm.c	2008-11-13 10:57:00.000000000 +0000
+++ b/binutils/nm.c	2009-04-28 17:08:10.000000000 +0100
@@ -178,6 +178,7 @@
 static bfd *lineno_cache_rel_bfd;
 
 #define OPTION_TARGET 200
+#define OPTION_PLUGIN 201
 
 static struct option long_options[] =
 {
@@ -192,6 +193,7 @@
   {"no-demangle", no_argument, &do_demangle, 0},
   {"no-sort", no_argument, &no_sort, 1},
   {"numeric-sort", no_argument, &sort_numerically, 1},
+  {"plugin", required_argument, 0, OPTION_PLUGIN},
   {"portability", no_argument, 0, 'P'},
   {"print-armap", no_argument, &print_armap, 1},
   {"print-file-name", no_argument, 0, 'o'},
@@ -1608,6 +1610,10 @@
 	  target = optarg;
 	  break;
 
+	case OPTION_PLUGIN:	/* --plugin */
+	  bfd_plugin_set_plugin (optarg);
+	  break;
+
 	case 0:		/* A long option that just sets a flag.  */
 	  break;
 
diff -ruN a/gas/Makefile.am b/gas/Makefile.am
--- a/gas/Makefile.am	2009-03-18 11:27:18.000000000 +0000
+++ b/gas/Makefile.am	2009-04-28 16:45:07.000000000 +0100
@@ -499,6 +499,10 @@
 BFDDIR = $(BASEDIR)/bfd
 INCDIR = $(BASEDIR)/include
 
+if PLUGINS
+LIBDL = -ldl
+endif
+
 # This is the variable actually used when we compile.
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
@@ -530,7 +534,7 @@
 
 as_new_SOURCES = $(GAS_CFILES)
 as_new_LDADD = $(TARG_CPU_O) $(OBJ_FORMAT_O) $(ATOF_TARG_O) \
-	$(extra_objects) $(GASLIBS) $(LIBINTL) $(LIBM)
+	$(extra_objects) $(GASLIBS) $(LIBINTL) $(LIBM) $(LIBDL)
 as_new_DEPENDENCIES = $(TARG_CPU_O) $(OBJ_FORMAT_O) $(ATOF_TARG_O) \
 	$(extra_objects) $(GASLIBS) $(LIBINTL_DEP)
 
diff -ruN a/gas/Makefile.in b/gas/Makefile.in
--- a/gas/Makefile.in	2009-03-18 11:27:18.000000000 +0000
+++ b/gas/Makefile.in	2009-04-28 16:45:07.000000000 +0100
@@ -201,6 +201,8 @@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -747,6 +749,7 @@
 BASEDIR = $(srcdir)/..
 BFDDIR = $(BASEDIR)/bfd
 INCDIR = $(BASEDIR)/include
+@PLUGINS_TRUE@LIBDL = -ldl
 
 # This is the variable actually used when we compile.
 # Specify the directories to be searched for header files.
@@ -779,7 +782,7 @@
 STAGESTUFF = *.o $(noinst_PROGRAMS)
 as_new_SOURCES = $(GAS_CFILES)
 as_new_LDADD = $(TARG_CPU_O) $(OBJ_FORMAT_O) $(ATOF_TARG_O) \
-	$(extra_objects) $(GASLIBS) $(LIBINTL) $(LIBM)
+	$(extra_objects) $(GASLIBS) $(LIBINTL) $(LIBM) $(LIBDL)
 
 as_new_DEPENDENCIES = $(TARG_CPU_O) $(OBJ_FORMAT_O) $(ATOF_TARG_O) \
 	$(extra_objects) $(GASLIBS) $(LIBINTL_DEP)
diff -ruN a/gas/configure b/gas/configure
--- a/gas/configure	2009-03-14 09:11:38.000000000 +0000
+++ b/gas/configure	2009-04-28 16:45:07.000000000 +0100
@@ -458,7 +458,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 WARN_CFLAGS NO_WERROR GDBINIT cgen_cpu_prefix extra_objects target_cpu_type obj_format te_file install_tooldir atof OPCODES_LIB YACC LEX LEXLIB LEX_OUTPUT_ROOT USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE ALLOCA LIBM datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 WARN_CFLAGS NO_WERROR GDBINIT cgen_cpu_prefix extra_objects target_cpu_type obj_format te_file install_tooldir atof OPCODES_LIB YACC LEX LEXLIB LEX_OUTPUT_ROOT USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE PLUGINS_TRUE PLUGINS_FALSE ALLOCA LIBM datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 ac_pwd=`pwd`
 
@@ -1017,6 +1017,7 @@
   --disable-nls           do not use Native Language Support
   --enable-maintainer-mode  enable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
+  --enable-plugins        linker plugins
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -5503,13 +5504,13 @@
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5506: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:5507: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5509: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:5510: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5512: output\"" >&5)
+  (eval echo "\"\$as_me:5513: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6666,7 +6667,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6669 "configure"' > conftest.$ac_ext
+  echo '#line 6670 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -7972,11 +7973,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:7975: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:7976: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:7979: \$? = $ac_status" >&5
+   echo "$as_me:7980: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8311,11 +8312,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8314: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8315: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8318: \$? = $ac_status" >&5
+   echo "$as_me:8319: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8416,11 +8417,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8419: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8420: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8423: \$? = $ac_status" >&5
+   echo "$as_me:8424: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8471,11 +8472,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8474: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8475: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8478: \$? = $ac_status" >&5
+   echo "$as_me:8479: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11283,7 +11284,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11286 "configure"
+#line 11287 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11379,7 +11380,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11382 "configure"
+#line 11383 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13384,6 +13385,28 @@
   GENINSRC_NEVER_FALSE=
 fi
 
+# Check whether --enable-plugins or --disable-plugins was given.
+if test "${enable_plugins+set}" = set; then
+  enableval="$enable_plugins"
+  case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac
+else
+  plugins=no
+fi;
+
+
+
+if test "$plugins" = "yes"; then
+  PLUGINS_TRUE=
+  PLUGINS_FALSE='#'
+else
+  PLUGINS_TRUE='#'
+  PLUGINS_FALSE=
+fi
+
 
 
 
@@ -15274,6 +15297,13 @@
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
@@ -16192,6 +16222,8 @@
 s,@MAINT@,$MAINT,;t t
 s,@GENINSRC_NEVER_TRUE@,$GENINSRC_NEVER_TRUE,;t t
 s,@GENINSRC_NEVER_FALSE@,$GENINSRC_NEVER_FALSE,;t t
+s,@PLUGINS_TRUE@,$PLUGINS_TRUE,;t t
+s,@PLUGINS_FALSE@,$PLUGINS_FALSE,;t t
 s,@ALLOCA@,$ALLOCA,;t t
 s,@LIBM@,$LIBM,;t t
 s,@datarootdir@,$datarootdir,;t t
diff -ruN a/gas/configure.in b/gas/configure.in
--- a/gas/configure.in	2009-03-14 09:11:38.000000000 +0000
+++ b/gas/configure.in	2009-04-28 16:45:07.000000000 +0100
@@ -604,6 +604,16 @@
 
 AM_MAINTAINER_MODE
 AM_CONDITIONAL(GENINSRC_NEVER, false)
+AC_ARG_ENABLE([plugins],
+[  --enable-plugins        linker plugins],
+[case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac],
+[plugins=no])
+
+AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
 AC_EXEEXT
 
 AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h limits.h)
diff -ruN a/gas/doc/Makefile.in b/gas/doc/Makefile.in
--- a/gas/doc/Makefile.in	2009-03-02 10:33:07.000000000 +0000
+++ b/gas/doc/Makefile.in	2009-04-28 16:45:07.000000000 +0100
@@ -156,6 +156,8 @@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
diff -ruN a/gprof/Makefile.am b/gprof/Makefile.am
--- a/gprof/Makefile.am	2009-03-03 02:41:13.000000000 +0000
+++ b/gprof/Makefile.am	2009-04-28 16:45:07.000000000 +0100
@@ -15,6 +15,10 @@
 NO_WERROR = @NO_WERROR@
 AM_CFLAGS = $(WARN_CFLAGS)
 
+if PLUGINS
+LIBDL = -ldl
+endif
+
 MKDEP = gcc -MM
 
 INCLUDES = -DDEBUG -I../bfd -I$(srcdir)/../include \
@@ -30,7 +34,7 @@
 	i386.c alpha.c vax.c tahoe.c sparc.c mips.c
 gprof_SOURCES = $(sources) flat_bl.c bsd_callg_bl.c fsf_callg_bl.c
 gprof_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a $(LIBINTL_DEP)
-gprof_LDADD = ../bfd/libbfd.la ../libiberty/libiberty.a $(LIBINTL)
+gprof_LDADD = ../bfd/libbfd.la ../libiberty/libiberty.a $(LIBINTL) $(LIBDL)
 
 noinst_HEADERS = \
 	basic_blocks.h call_graph.h cg_arcs.h cg_dfn.h cg_print.h \
diff -ruN a/gprof/Makefile.in b/gprof/Makefile.in
--- a/gprof/Makefile.in	2009-03-03 02:41:13.000000000 +0000
+++ b/gprof/Makefile.in	2009-04-28 16:45:07.000000000 +0100
@@ -189,6 +189,8 @@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -262,6 +264,7 @@
 BFDDIR = $(BASEDIR)/bfd
 INCDIR = $(BASEDIR)/include
 AM_CFLAGS = $(WARN_CFLAGS)
+@PLUGINS_TRUE@LIBDL = -ldl
 MKDEP = gcc -MM
 INCLUDES = -DDEBUG -I../bfd -I$(srcdir)/../include \
 	-I$(srcdir)/../bfd @INCINTL@ -I. \
@@ -274,7 +277,7 @@
 
 gprof_SOURCES = $(sources) flat_bl.c bsd_callg_bl.c fsf_callg_bl.c
 gprof_DEPENDENCIES = ../bfd/libbfd.la ../libiberty/libiberty.a $(LIBINTL_DEP)
-gprof_LDADD = ../bfd/libbfd.la ../libiberty/libiberty.a $(LIBINTL)
+gprof_LDADD = ../bfd/libbfd.la ../libiberty/libiberty.a $(LIBINTL) $(LIBDL)
 noinst_HEADERS = \
 	basic_blocks.h call_graph.h cg_arcs.h cg_dfn.h cg_print.h \
 	corefile.h gmon.h gmon_io.h gmon_out.h gprof.h hertz.h hist.h \
diff -ruN a/gprof/configure b/gprof/configure
--- a/gprof/configure	2009-03-01 18:57:18.000000000 +0000
+++ b/gprof/configure	2009-04-28 16:45:07.000000000 +0100
@@ -458,7 +458,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE WARN_CFLAGS NO_WERROR datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE PLUGINS_TRUE PLUGINS_FALSE WARN_CFLAGS NO_WERROR datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 ac_pwd=`pwd`
 
@@ -1013,6 +1013,7 @@
   --disable-nls           do not use Native Language Support
   --enable-maintainer-mode  enable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
+  --enable-plugins        linker plugins
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
 
@@ -5595,13 +5596,13 @@
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5598: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:5599: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5601: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:5602: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5604: output\"" >&5)
+  (eval echo "\"\$as_me:5605: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6758,7 +6759,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6761 "configure"' > conftest.$ac_ext
+  echo '#line 6762 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -8064,11 +8065,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8067: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8068: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8071: \$? = $ac_status" >&5
+   echo "$as_me:8072: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8403,11 +8404,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8406: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8407: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8410: \$? = $ac_status" >&5
+   echo "$as_me:8411: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8508,11 +8509,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8511: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8512: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8515: \$? = $ac_status" >&5
+   echo "$as_me:8516: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8563,11 +8564,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8566: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8567: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8570: \$? = $ac_status" >&5
+   echo "$as_me:8571: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11375,7 +11376,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11378 "configure"
+#line 11379 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11471,7 +11472,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11474 "configure"
+#line 11475 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12217,6 +12218,28 @@
   GENINSRC_NEVER_FALSE=
 fi
 
+# Check whether --enable-plugins or --disable-plugins was given.
+if test "${enable_plugins+set}" = set; then
+  enableval="$enable_plugins"
+  case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac
+else
+  plugins=no
+fi;
+
+
+
+if test "$plugins" = "yes"; then
+  PLUGINS_TRUE=
+  PLUGINS_FALSE='#'
+else
+  PLUGINS_TRUE='#'
+  PLUGINS_FALSE=
+fi
+
 
 
 
@@ -12750,6 +12773,13 @@
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
@@ -13645,6 +13675,8 @@
 s,@MAINT@,$MAINT,;t t
 s,@GENINSRC_NEVER_TRUE@,$GENINSRC_NEVER_TRUE,;t t
 s,@GENINSRC_NEVER_FALSE@,$GENINSRC_NEVER_FALSE,;t t
+s,@PLUGINS_TRUE@,$PLUGINS_TRUE,;t t
+s,@PLUGINS_FALSE@,$PLUGINS_FALSE,;t t
 s,@WARN_CFLAGS@,$WARN_CFLAGS,;t t
 s,@NO_WERROR@,$NO_WERROR,;t t
 s,@datarootdir@,$datarootdir,;t t
diff -ruN a/gprof/configure.in b/gprof/configure.in
--- a/gprof/configure.in	2009-02-03 15:54:04.000000000 +0000
+++ b/gprof/configure.in	2009-04-28 16:45:07.000000000 +0100
@@ -33,6 +33,16 @@
 
 AM_MAINTAINER_MODE
 AM_CONDITIONAL(GENINSRC_NEVER, false)
+AC_ARG_ENABLE([plugins],
+[  --enable-plugins        linker plugins],
+[case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac],
+[plugins=no])
+
+AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
 AC_EXEEXT
 
 AC_CHECK_HEADERS(sys/gmon_out.h)
diff -ruN a/ld/Makefile.am b/ld/Makefile.am
--- a/ld/Makefile.am	2009-04-16 16:39:45.000000000 +0100
+++ b/ld/Makefile.am	2009-04-28 16:45:07.000000000 +0100
@@ -108,6 +108,10 @@
 BFDLIB = ../bfd/libbfd.la
 LIBIBERTY = ../libiberty/libiberty.a
 
+if PLUGINS
+LIBDL = -ldl
+endif
+
 ALL_EMULATIONS = \
 	eaixppc.o \
 	eaixrs6.o \
@@ -1748,7 +1752,7 @@
 ld_new_SOURCES = ldgram.y ldlex.l lexsup.c ldlang.c mri.c ldctor.c ldmain.c \
 	ldwrite.c ldexp.c ldemul.c ldver.c ldmisc.c ldfile.c ldcref.c
 ld_new_DEPENDENCIES = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL_DEP)
-ld_new_LDADD = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+ld_new_LDADD = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDL)
 
 # The generated emulation files mostly have the same dependencies.
 $(EMULATION_OFILES): ../bfd/bfd.h sysdep.h config.h $(INCDIR)/bfdlink.h \
diff -ruN a/ld/Makefile.in b/ld/Makefile.in
--- a/ld/Makefile.in	2009-04-16 16:39:46.000000000 +0100
+++ b/ld/Makefile.in	2009-04-28 16:45:07.000000000 +0100
@@ -221,6 +221,8 @@
 PACKAGE_TARNAME = @PACKAGE_TARNAME@
 PACKAGE_VERSION = @PACKAGE_VERSION@
 PATH_SEPARATOR = @PATH_SEPARATOR@
+PLUGINS_FALSE = @PLUGINS_FALSE@
+PLUGINS_TRUE = @PLUGINS_TRUE@
 POSUB = @POSUB@
 RANLIB = @RANLIB@
 SED = @SED@
@@ -373,6 +375,7 @@
 
 BFDLIB = ../bfd/libbfd.la
 LIBIBERTY = ../libiberty/libiberty.a
+@PLUGINS_TRUE@LIBDL = -ldl
 ALL_EMULATIONS = \
 	eaixppc.o \
 	eaixrs6.o \
@@ -732,7 +735,7 @@
 	ldwrite.c ldexp.c ldemul.c ldver.c ldmisc.c ldfile.c ldcref.c
 
 ld_new_DEPENDENCIES = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL_DEP)
-ld_new_LDADD = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL)
+ld_new_LDADD = $(EMULATION_OFILES) $(EMUL_EXTRA_OFILES) $(BFDLIB) $(LIBIBERTY) $(LIBINTL) $(LIBDL)
 MAINTAINERCLEANFILES = configdoc.texi ld.info
 
 # We want to reconfigure if configure.host or configure.tgt changes.  We
diff -ruN a/ld/configure b/ld/configure
--- a/ld/configure	2009-03-17 05:01:25.000000000 +0000
+++ b/ld/configure	2009-04-28 16:45:07.000000000 +0100
@@ -458,7 +458,7 @@
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE use_sysroot TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS NO_WERROR CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE YACC LEX LEXLIB LEX_OUTPUT_ROOT MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE do_compare HDEFINES HOSTING_CRT0 HOSTING_LIBS NATIVE_LIB_DIRS STRINGIFY EMUL EMULATION_OFILES EMUL_EXTRA_OFILES LIB_PATH EMULATION_LIBPATH TESTBFDLIB datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP ac_ct_STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE use_sysroot TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE WARN_CFLAGS NO_WERROR CPP EGREP LIBTOOL SED FGREP GREP LD DUMPBIN ac_ct_DUMPBIN NM LN_S OBJDUMP ac_ct_OBJDUMP AR ac_ct_AR RANLIB ac_ct_RANLIB lt_ECHO DSYMUTIL ac_ct_DSYMUTIL NMEDIT ac_ct_NMEDIT LIPO ac_ct_LIPO OTOOL ac_ct_OTOOL OTOOL64 ac_ct_OTOOL64 USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS DATADIRNAME INSTOBJEXT GENCAT CATOBJEXT MKINSTALLDIRS MSGFMT MSGMERGE YACC LEX LEXLIB LEX_OUTPUT_ROOT MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT GENINSRC_NEVER_TRUE GENINSRC_NEVER_FALSE do_compare PLUGINS_TRUE PLUGINS_FALSE HDEFINES HOSTING_CRT0 HOSTING_LIBS NATIVE_LIB_DIRS STRINGIFY EMUL EMULATION_OFILES EMUL_EXTRA_OFILES LIB_PATH EMULATION_LIBPATH TESTBFDLIB datarootdir docdir htmldir pdfdir LIBOBJS LTLIBOBJS'
 ac_subst_files='TDIRS'
 ac_pwd=`pwd`
 
@@ -1019,6 +1019,7 @@
   --disable-nls           do not use Native Language Support
   --enable-maintainer-mode  enable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
+  --enable-plugins        linker plugins
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -5795,13 +5796,13 @@
 else
   lt_cv_nm_interface="BSD nm"
   echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:5798: $ac_compile\"" >&5)
+  (eval echo "\"\$as_me:5799: $ac_compile\"" >&5)
   (eval "$ac_compile" 2>conftest.err)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5801: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval echo "\"\$as_me:5802: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   cat conftest.err >&5
-  (eval echo "\"\$as_me:5804: output\"" >&5)
+  (eval echo "\"\$as_me:5805: output\"" >&5)
   cat conftest.out >&5
   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
     lt_cv_nm_interface="MS dumpbin"
@@ -6958,7 +6959,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 6961 "configure"' > conftest.$ac_ext
+  echo '#line 6962 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -8264,11 +8265,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8267: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8268: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8271: \$? = $ac_status" >&5
+   echo "$as_me:8272: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8603,11 +8604,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8606: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8607: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:8610: \$? = $ac_status" >&5
+   echo "$as_me:8611: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings other than the usual output.
@@ -8708,11 +8709,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8711: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8712: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8715: \$? = $ac_status" >&5
+   echo "$as_me:8716: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -8763,11 +8764,11 @@
    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:8766: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:8767: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:8770: \$? = $ac_status" >&5
+   echo "$as_me:8771: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -11575,7 +11576,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11578 "configure"
+#line 11579 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11671,7 +11672,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11674 "configure"
+#line 11675 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12666,6 +12667,29 @@
 
 
 
+# Check whether --enable-plugins or --disable-plugins was given.
+if test "${enable_plugins+set}" = set; then
+  enableval="$enable_plugins"
+  case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac
+else
+  plugins=no
+fi;
+
+
+
+if test "$plugins" = "yes"; then
+  PLUGINS_TRUE=
+  PLUGINS_FALSE='#'
+else
+  PLUGINS_TRUE='#'
+  PLUGINS_FALSE=
+fi
+
+
 . ${srcdir}/configure.host
 
 
@@ -14709,6 +14733,13 @@
 Usually this means the macro was only invoked conditionally." >&2;}
    { (exit 1); exit 1; }; }
 fi
+if test -z "${PLUGINS_TRUE}" && test -z "${PLUGINS_FALSE}"; then
+  { { echo "$as_me:$LINENO: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&5
+echo "$as_me: error: conditional \"PLUGINS\" was never defined.
+Usually this means the macro was only invoked conditionally." >&2;}
+   { (exit 1); exit 1; }; }
+fi
 
 : ${CONFIG_STATUS=./config.status}
 ac_clean_files_save=$ac_clean_files
@@ -15614,6 +15645,8 @@
 s,@GENINSRC_NEVER_TRUE@,$GENINSRC_NEVER_TRUE,;t t
 s,@GENINSRC_NEVER_FALSE@,$GENINSRC_NEVER_FALSE,;t t
 s,@do_compare@,$do_compare,;t t
+s,@PLUGINS_TRUE@,$PLUGINS_TRUE,;t t
+s,@PLUGINS_FALSE@,$PLUGINS_FALSE,;t t
 s,@HDEFINES@,$HDEFINES,;t t
 s,@HOSTING_CRT0@,$HOSTING_CRT0,;t t
 s,@HOSTING_LIBS@,$HOSTING_LIBS,;t t
diff -ruN a/ld/configure.in b/ld/configure.in
--- a/ld/configure.in	2009-03-17 05:01:25.000000000 +0000
+++ b/ld/configure.in	2009-04-28 16:45:07.000000000 +0100
@@ -127,6 +127,17 @@
 AM_CONDITIONAL(GENINSRC_NEVER, false)
 ACX_PROG_CMP_IGNORE_INITIAL
 
+AC_ARG_ENABLE([plugins],
+[  --enable-plugins        linker plugins],
+[case "${enableval}" in
+  yes | "") plugins=yes ;;
+  no) plugins=no ;;
+  *) plugins=yes ;;
+ esac],
+[plugins=no])
+
+AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
+
 . ${srcdir}/configure.host
 
 AC_SUBST(HDEFINES)
int f(void);
int main (void) {
  return f();
}
int f(void) {
  return 42;
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]