Move struct plugin_data_struct to plugin.c

Alan Modra amodra@gmail.com
Thu Aug 7 13:14:59 GMT 2025


It isn't needed anywhere except plugin.c.  The typedef can disappear.
Also make a forward declaraion for ld_plugin_input_file in plugin.h
so that this header can be used without first including plugin-api.h.

bfd/
	* plugin.h (struct ld_plugin_input_file): Forward declare.
	(struct plugin_data_struct): Move to..
	* plugin.c: ..here.
	(add_symbols): Size plugin_data without using type.
	* archive.c: Don't include plugin-api.h.
	* elflink.c: Likewise.
	* format.c: Likewise.
binutils/
	* ar.c: Don't include plugin-api.h or ansidecl.h.  Only
	include plugin.h when BFD_SUPPORTS_PLUGINS.
	* nm.c: Don't include plugin-api.h.  Only include plugin.h
	when BFD_SUPPORTS_PLUGINS.
	* objcopy.c: Likewise.
ld/
	* ldfile.c: Don't include plugin-api.h.
	* ldmain.c: Likewise.

diff --git a/bfd/archive.c b/bfd/archive.c
index 697b2ed23f2..52d31199fdd 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -142,7 +142,6 @@ SUBSECTION
 #include "filenames.h"
 #include "bfdlink.h"
 #if BFD_SUPPORTS_PLUGINS
-#include "plugin-api.h"
 #include "plugin.h"
 #endif
 
diff --git a/bfd/elflink.c b/bfd/elflink.c
index c4f57cf2f3c..cdd58b25fc8 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -28,7 +28,6 @@
 #include "libiberty.h"
 #include "objalloc.h"
 #if BFD_SUPPORTS_PLUGINS
-#include "plugin-api.h"
 #include "plugin.h"
 #endif
 
diff --git a/bfd/format.c b/bfd/format.c
index bd9fa8d6c33..fba8d2a3d37 100644
--- a/bfd/format.c
+++ b/bfd/format.c
@@ -47,7 +47,6 @@ SUBSECTION
 #include "bfd.h"
 #include "libbfd.h"
 #if BFD_SUPPORTS_PLUGINS
-#include "plugin-api.h"
 #include "plugin.h"
 #endif
 
diff --git a/bfd/plugin.c b/bfd/plugin.c
index 43ca444e7a1..733e7f0f322 100644
--- a/bfd/plugin.c
+++ b/bfd/plugin.c
@@ -138,6 +138,14 @@ struct plugin_list_entry
   const char *plugin_name;
 };
 
+struct plugin_data_struct
+{
+  int nsyms;
+  const struct ld_plugin_symbol *syms;
+  int object_only_nsyms;
+  asymbol **object_only_syms;
+};
+
 static const char *plugin_program_name;
 
 void
@@ -336,9 +344,8 @@ add_symbols (void * handle,
 	     const struct ld_plugin_symbol * syms)
 {
   bfd *abfd = handle;
-  struct plugin_data_struct *plugin_data =
-    bfd_alloc (abfd, sizeof (plugin_data_struct));
-
+  struct plugin_data_struct *plugin_data = bfd_alloc (abfd,
+						      sizeof (*plugin_data));
   if (!plugin_data)
     return LDPS_ERR;
 
diff --git a/bfd/plugin.h b/bfd/plugin.h
index 6acb5fa9c86..d981c517996 100644
--- a/bfd/plugin.h
+++ b/bfd/plugin.h
@@ -21,6 +21,8 @@
 #ifndef _PLUGIN_H_
 #define _PLUGIN_H_
 
+struct ld_plugin_input_file;
+
 void bfd_plugin_set_program_name (const char *);
 int bfd_plugin_open_input (bfd *, struct ld_plugin_input_file *);
 void bfd_plugin_set_plugin (const char *);
@@ -29,13 +31,4 @@ bool bfd_link_plugin_object_p (bfd *);
 void register_ld_plugin_object_p (bfd_cleanup (*object_p) (bfd *, bool));
 void bfd_plugin_close_file_descriptor (bfd *, int);
 
-typedef struct plugin_data_struct
-{
-  int nsyms;
-  const struct ld_plugin_symbol *syms;
-  int object_only_nsyms;
-  asymbol **object_only_syms;
-}
-plugin_data_struct;
-
 #endif
diff --git a/binutils/ar.c b/binutils/ar.c
index de41c9e3dd1..3cac3f3fb26 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -32,9 +32,9 @@
 #include "arsup.h"
 #include "filenames.h"
 #include "binemul.h"
-#include "plugin-api.h"
+#if BFD_SUPPORTS_PLUGINS
 #include "plugin.h"
-#include "ansidecl.h"
+#endif
 
 #ifdef __GO32___
 #define EXT_NAME_LEN 3		/* Bufflen of addition to name if it's MS-DOS.  */
diff --git a/binutils/nm.c b/binutils/nm.c
index d44083dcc94..a7f0e9d9409 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -36,9 +36,10 @@
 #include "libcoff.h"
 #include "bucomm.h"
 #include "demanguse.h"
-#include "plugin-api.h"
-#include "plugin.h"
 #include "safe-ctype.h"
+#if BFD_SUPPORTS_PLUGINS
+#include "plugin.h"
+#endif
 
 #ifndef streq
 #define streq(a,b) (strcmp ((a),(b)) == 0)
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 3404bec1d08..654d2b9b44a 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -30,8 +30,9 @@
 #include "coff/internal.h"
 #include "libcoff.h"
 #include "safe-ctype.h"
-#include "plugin-api.h"
+#if BFD_SUPPORTS_PLUGINS
 #include "plugin.h"
+#endif
 
 /* FIXME: See bfd/peXXigen.c for why we include an architecture specific
    header in generic PE code.  */
diff --git a/ld/ldfile.c b/ld/ldfile.c
index 75fd360d5e3..e642c7f6620 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -36,7 +36,6 @@
 #include "filenames.h"
 #include <fnmatch.h>
 #if BFD_SUPPORTS_PLUGINS
-#include "plugin-api.h"
 #include "plugin.h"
 #endif /* BFD_SUPPORTS_PLUGINS */
 
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 67c60c3f80d..13b8e3dce9d 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -42,7 +42,6 @@
 #include "ldctor.h"
 #if BFD_SUPPORTS_PLUGINS
 #include "plugin.h"
-#include "plugin-api.h"
 #endif /* BFD_SUPPORTS_PLUGINS */
 
 /* Somewhere above, sys/stat.h got included.  */

-- 
Alan Modra


More information about the Binutils mailing list