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]

Re: new plugin bfd_target breaks gdb with --enable-targets=all


> I would prefer that. ÂWe do the similar thing for
> libiberty's xmalloc (xmalloc_set_program_name). ÂCould
> also be new bfd_set_program_name|bfd_get_program_name pair, the
> former called even if not supporting plugins, but I'm not a
> binutils maintainer, so that's just a suggestion.

I did the plugin specific version. So far it is the only thing in bfd
that uses the program name.

bfd/
2009-05-27  Rafael Avila de Espindola  <espindola@google.com>

	* plugin.c (program_name): Remove.
	(plugin_program_name): New.
	(bfd_plugin_set_program_name): New.
	(try_load_plugin): Use plugin_program_name.
	* plugin.h (bfd_plugin_set_program_name): New.

binutils/
2009-05-27  Rafael Avila de Espindola  <espindola@google.com>

	* ar.c (main): Call bfd_plugin_set_program_name.
	* nm.c (main): Call bfd_plugin_set_program_name.

>> The plugin is just a strange target. That is why it is included in
>> --enable-targets=all.
>
> :-) That's not an explanation, but I guess it's fine to have it
> included in --enable-targets=all as long as it doesn't try
> to get built on non -dl capable hosts.

I actually think that building the plugin target is correct if given
--enable-targets=all. I read that option as "support as many files
types as possible". Adding plugin adds at least one more file type
(llvm bitcode).

It looks like the patch that was committed was a slightly old version
where --enable-plugins in not the same as adding plugins to targets.
Nick, any reason why you committed that one?

> --
> Pedro Alves
>

Cheers,
-- 
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 49395e8..aea4969 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -106,7 +106,13 @@ add_symbols (void * handle,
   return LDPS_OK;
 }
 
-extern char *program_name __attribute__ ((weak));
+static const char *plugin_program_name;
+
+void
+bfd_plugin_set_program_name (const char *program_name)
+{
+  plugin_program_name = program_name;
+}
 
 static int
 try_load_plugin (const char *pname)
@@ -180,11 +186,11 @@ load_plugin (void)
   if (plugin_name)
     return try_load_plugin (plugin_name);
 
-  if (!program_name)
+  if (!plugin_program_name)
     return 0;
 
   plugin_dir = concat (BINDIR, "/../lib/bfd-plugins", NULL);
-  p = make_relative_prefix (program_name,
+  p = make_relative_prefix (plugin_program_name,
 			    BINDIR,
 			    plugin_dir);
   free (plugin_dir);
diff --git a/bfd/plugin.h b/bfd/plugin.h
index 2fae2de..3091f97 100644
--- a/bfd/plugin.h
+++ b/bfd/plugin.h
@@ -23,6 +23,7 @@
 
 #include "bfd.h"
 
+void bfd_plugin_set_program_name (const char *);
 void bfd_plugin_set_plugin (const char *);
 
 typedef struct plugin_data_struct
diff --git a/binutils/ar.c b/binutils/ar.c
index d28419f..318cfe0 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -392,6 +392,9 @@ main (int argc, char **argv)
 
   program_name = argv[0];
   xmalloc_set_program_name (program_name);
+#if BFD_SUPPORTS_PLUGINS
+  bfd_plugin_set_program_name (program_name);
+#endif
 
   expandargv (&argc, &argv);
 
diff --git a/binutils/nm.c b/binutils/nm.c
index b03d1b6..51f67d1 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -1515,6 +1515,9 @@ main (int argc, char **argv)
 
   program_name = *argv;
   xmalloc_set_program_name (program_name);
+#if BFD_SUPPORTS_PLUGINS
+  bfd_plugin_set_program_name (program_name);
+#endif
 
   START_PROGRESS (program_name, 0);
 

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