[PATCH] libbfd: Always compile plugin.c into libbfd

Jan Beulich jbeulich@suse.com
Thu Aug 7 08:47:56 GMT 2025


On 06.08.2025 20:21, H.J. Lu wrote:
> Always compile plugin.c into libbfd.  Add bfd_plugin_enabled() to check
> if plugin is enabled in libbfd.  Change bfd_plugin_object_p() to return
> NULL if plugin isn't enabled in BFD so that
> 
> BFD_SEND_FMT (abfd, _bfd_check_format, (abfd))
> 
> returns NULL when the plugin target is in use.  This makes the plugin
> target unused when plugin isn't enabled in BFD.  Move BFD_SUPPORTS_PLUGINS
> to bfd/config.h, which is checked only in bfd/plugin.c so that all plugin
> related functions can be used unconditionally.
> 
> bfd/
> 
> 	* Makefile.am (BFD32_LIBS): Add plugin.lo.
> 	(BFD32_LIBS_CFILES): Add plugin.c.
> 	(BFD_H_FILES): Likewise.
> 	* Makefile.in: Regenerated.
> 	* archive.c: Include plugin-api.h and plugin.h unconditionally.
> 	(_bfd_compute_and_write_armap): Remove the BFD_SUPPORTS_PLUGINS
> 	check.
> 	* bfd-in.h (BFD_SUPPORTS_PLUGINS): Removed.
> 	* bfd-in2.h: Regenerated.
> 	* config.in: Likewise.
> 	* configure: Likewise.
> 	* configure.ac (tb): Don't append plugin.lo.
> 	(supports_plugins): Don't do AC_SUBST.
> 	(BFD_SUPPORTS_PLUGINS): Add AC_DEFINE_UNQUOTED.
> 	* elflink.c: Include plugin-api.h and plugin.h unconditionally.
> 	(elf_link_is_defined_archive_symbol): Remove the
> 	BFD_SUPPORTS_PLUGINS check.
> 	* format.c: Include plugin-api.h and plugin.h unconditionally.
> 	(bfd_set_lto_type): Remove the BFD_SUPPORTS_PLUGINS check.
> 	(bfd_check_format_matches): Likewise.
> 	* libbfd.h: Regenerated.
> 	* plugin.c: Remove the BFD_SUPPORTS_PLUGINS check.
> 	(PLUGIN_ENABLED): New.
> 	(bfd_plugin_enabled): Likewise.
> 	(bfd_plugin_set_program_name): Set plugin_program_name only if
> 	PLUGIN_ENABLED is non-zero.
> 	(bfd_plugin_object_p): Return NULL if PLUGIN_ENABLED is zero.
> 	* targets.c (_bfd_target_vector): Remove the BFD_SUPPORTS_PLUGINS
> 	check.
> 	* xtensa-dynconfig.c (xtensa_load_config): Replace the
> 	BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call.
> 
> ar/
> 
> 	* ar.c: Include plugin-api.h and plugin.h unconditionally.
> 	(plugin_target): Remove the BFD_SUPPORTS_PLUGINS check.
> 	(usage): Replace the BFD_SUPPORTS_PLUGINS check with the
> 	bfd_plugin_enabled call.
> 	(ranlib_usage): Likewise.
> 	(decode_options): Likewise.
> 	(ranlib_main): Likewise.
> 	(main): Call bfd_plugin_set_program_name unconditionally.
> 	* arsup.c (ar_open): Likewise.
> 	* nm.c (plugin_target): Likewise.
> 	(usage): Replace the BFD_SUPPORTS_PLUGINS check with the
> 	bfd_plugin_enabled call.
> 	(filter_symbols): Remove the BFD_SUPPORTS_PLUGINS check.
> 	(main): Call bfd_plugin_set_program_name unconditionally.  Replace
> 	the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call.
> 	* objcopy.c (lto_sections_removed): Remove the BFD_SUPPORTS_PLUGINS
> 	check.
> 	(strip_usage): Replace the BFD_SUPPORTS_PLUGINS check with the
> 	bfd_plugin_enabled call.
> 	(copy_archive): Remove the BFD_SUPPORTS_PLUGINS check.
> 	(check_format_object): Likewise.
> 	(copy_file): Likewise.
> 	(strip_main): Call bfd_plugin_set_program_name unconditionally.
> 	Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled
> 	call.  Remove the BFD_SUPPORTS_PLUGINS check.
> 
> ld/
> 
> 	* ldfile.c: Include plugin-api.h and plugin.h unconditionally.
> 	(ldfile_try_open_bfd): Remove the BFD_SUPPORTS_PLUGINS check.
> 	* ldlang.c: Include plugin.h unconditionally.
> 	(plugin_insert): Remove the BFD_SUPPORTS_PLUGINS check.
> 	(plugin_undefs): Likewise.
> 	(open_input_bfds): Likewise.
> 	(lang_check): Likewise.
> 	(lang_gc_sections): Likewise.
> 	(find_next_input_statement): Likewise.
> 	(lang_process): Likewise.
> 	* ldlang.h (lang_input_statement_flags): Likewise.
> 	* ldlex.h (option_values): Likewise.
> 	* ldmain.c: Include plugin-api.h and plugin.h unconditionally.
> 	(ld_cleanup): Remove the BFD_SUPPORTS_PLUGINS check.
> 	(main): Likewise.
> 	(add_archive_element): Likewise.
> 	* lexsup.c: Include plugin.h unconditionally.
> 	(ld_options): Remove the BFD_SUPPORTS_PLUGINS check.
> 	(parse_args): Replace the BFD_SUPPORTS_PLUGINS check with the
> 	bfd_plugin_enabled call.  Remove the BFD_SUPPORTS_PLUGINS check.
> 	(help): Append " (ignored)" to plugin options if bfd_plugin_enabled
> 	return false.
> 	* libdep_plugin.c: Remove the BFD_SUPPORTS_PLUGINS check.
> 	* plugin.c: Likewise.
> 	* testplug.c: Likewise.
> 	* testplug2.c: Likewise.
> 	* testplug3.c: Likewise.
> 	* testplug4.c: Likewise.
> 
> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>

As indicated, I disagree with any adding of entirely dead code to an already
too large (in many cases) library. It's not a huge amount of code, but still
it moves us into the wrong direction, imo. I do not, however, disagree enough
to outright reject this change - if Nick and/or Alan think it's okay to do go
this route, then so be it.

Jan


More information about the Binutils mailing list