forked from Imagelibrary/binutils-gdb
Limit BFD_SUPPORTS_PLUGINS check to plugin.h and targets.c
Minimize the BFD_SUPPORTS_PLUGINS check to make code more readable and maintainable by: 1. Update bfd/plugin.h to define plugin functions as static inline if BFD_SUPPORTS_PLUGINS is 0. 2. Remove BFD_SUPPORTS_PLUGINS check from all bfd and binutils files except plugin.h and targets.c. 3. Replace the remaining BFD_SUPPORTS_PLUGINS checks with a function so that plugin availability is checked at run time. bfd/ * archive.c: Include plugin.h unconditionally. (_bfd_compute_and_write_armap): Remove the BFD_SUPPORTS_PLUGINS check. * bfd-in.h (bfd_plugin_enabled): New. * bfd-in2.h: Regenerated. * elflink.c: Include plugin.h unconditionally. (elf_link_is_defined_archive_symbol): Remove the BFD_SUPPORTS_PLUGINS check. * format.c: Include plugin.h unconditionally. (bfd_set_lto_type): Remove the BFD_SUPPORTS_PLUGINS check. (bfd_check_format_matches): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. Replace plugin_vec with bfd_plugin_vec. Remove the BFD_SUPPORTS_PLUGINS check. * plugin.c (bfd_plugin_target_p): Removed. * plugin.h (bfd_plugin_vec): New. (bfd_plugin_target_p): Likewise. (bfd_plugin_set_program_name): New. Static inline function if BFD_SUPPORTS_PLUGINS is 0. (bfd_plugin_open_input): Likewise. (bfd_plugin_set_plugin): Likewise. (bfd_link_plugin_object_p): Likewise. (register_ld_plugin_object_p): Likewise. (bfd_plugin_close_file_descriptor): Likewise. (bfd_plugin_vec): Likewise. (bfd_plugin_target_p): Likewise. * xtensa-dynconfig.c (xtensa_load_config): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. ar/ * ar.c: Include plugin.h unconditionally. (plugin_target): Removed. (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. * nm.c: Include plugin.h unconditionally. (plugin_target): Removed. (usage): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. (filter_symbols): Remove the BFD_SUPPORTS_PLUGINS check. (display_rel_file): Likewise. (main): Call bfd_plugin_set_program_name unconditionally. Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. * objcopy.c: Include plugin.h unconditionally. (strip_usage): Replace the BFD_SUPPORTS_PLUGINS check with the bfd_plugin_enabled call. (copy_archive): Remove the BFD_SUPPORTS_PLUGINS check. Replace BFD_SUPPORTS_PLUGINS with the bfd_plugin_enabled call. (copy_file): Likewise. (strip_main): Likewise. ld/ * ldfile.c: Include 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.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. Co-Authored-By: Alan Modra <amodra@gmail.com> Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
This commit is contained in:
@@ -32,9 +32,7 @@
|
||||
#include "arsup.h"
|
||||
#include "filenames.h"
|
||||
#include "binemul.h"
|
||||
#if BFD_SUPPORTS_PLUGINS
|
||||
#include "plugin.h"
|
||||
#endif
|
||||
|
||||
#ifdef __GO32___
|
||||
#define EXT_NAME_LEN 3 /* Bufflen of addition to name if it's MS-DOS. */
|
||||
@@ -270,18 +268,18 @@ usage (int help)
|
||||
{
|
||||
FILE *s;
|
||||
|
||||
#if BFD_SUPPORTS_PLUGINS
|
||||
/* xgettext:c-format */
|
||||
const char *command_line
|
||||
= _("Usage: %s [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV]"
|
||||
" [--plugin <name>] [member-name] [count] archive-file file...\n");
|
||||
const char *command_line;
|
||||
if (bfd_plugin_enabled ())
|
||||
/* xgettext:c-format */
|
||||
command_line
|
||||
= _("Usage: %s [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV]"
|
||||
" [--plugin <name>] [member-name] [count] archive-file file...\n");
|
||||
else
|
||||
/* xgettext:c-format */
|
||||
command_line
|
||||
= _("Usage: %s [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV]"
|
||||
" [member-name] [count] archive-file file...\n");
|
||||
|
||||
#else
|
||||
/* xgettext:c-format */
|
||||
const char *command_line
|
||||
= _("Usage: %s [emulation options] [-]{dmpqrstx}[abcDfilMNoOPsSTuvV]"
|
||||
" [member-name] [count] archive-file file...\n");
|
||||
#endif
|
||||
s = help ? stdout : stderr;
|
||||
|
||||
fprintf (s, command_line, program_name);
|
||||
@@ -333,10 +331,11 @@ usage (int help)
|
||||
fprintf (s, _(" --output=DIRNAME - specify the output directory for extraction operations\n"));
|
||||
fprintf (s, _(" --record-libdeps=<text> - specify the dependencies of this library\n"));
|
||||
fprintf (s, _(" --thin - make a thin archive\n"));
|
||||
#if BFD_SUPPORTS_PLUGINS
|
||||
fprintf (s, _(" optional:\n"));
|
||||
fprintf (s, _(" --plugin <p> - load the specified plugin\n"));
|
||||
#endif
|
||||
if (bfd_plugin_enabled ())
|
||||
{
|
||||
fprintf (s, _(" optional:\n"));
|
||||
fprintf (s, _(" --plugin <p> - load the specified plugin\n"));
|
||||
}
|
||||
|
||||
ar_emul_usage (s);
|
||||
|
||||
@@ -360,10 +359,9 @@ ranlib_usage (int help)
|
||||
fprintf (s, _(" Generate an index to speed access to archives\n"));
|
||||
fprintf (s, _(" The options are:\n\
|
||||
@<file> Read options from <file>\n"));
|
||||
#if BFD_SUPPORTS_PLUGINS
|
||||
fprintf (s, _("\
|
||||
if (bfd_plugin_enabled ())
|
||||
fprintf (s, _("\
|
||||
--plugin <name> Load the specified plugin\n"));
|
||||
#endif
|
||||
if (DEFAULT_AR_DETERMINISTIC)
|
||||
fprintf (s, _("\
|
||||
-D Use zero for symbol map timestamp (default)\n\
|
||||
@@ -590,12 +588,9 @@ decode_options (int argc, char **argv)
|
||||
deterministic = false;
|
||||
break;
|
||||
case OPTION_PLUGIN:
|
||||
#if BFD_SUPPORTS_PLUGINS
|
||||
if (!bfd_plugin_enabled ())
|
||||
fatal (_("sorry - this program has been built without plugin support\n"));
|
||||
bfd_plugin_set_plugin (optarg);
|
||||
#else
|
||||
fprintf (stderr, _("sorry - this program has been built without plugin support\n"));
|
||||
xexit (1);
|
||||
#endif
|
||||
break;
|
||||
case OPTION_TARGET:
|
||||
target = optarg;
|
||||
@@ -665,12 +660,9 @@ ranlib_main (int argc, char **argv)
|
||||
|
||||
/* PR binutils/13493: Support plugins. */
|
||||
case OPTION_PLUGIN:
|
||||
#if BFD_SUPPORTS_PLUGINS
|
||||
if (!bfd_plugin_enabled ())
|
||||
fatal (_("sorry - this program has been built without plugin support\n"));
|
||||
bfd_plugin_set_plugin (optarg);
|
||||
#else
|
||||
fprintf (stderr, _("sorry - this program has been built without plugin support\n"));
|
||||
xexit (1);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -721,9 +713,7 @@ main (int argc, char **argv)
|
||||
program_name = argv[0];
|
||||
xmalloc_set_program_name (program_name);
|
||||
bfd_set_error_program_name (program_name);
|
||||
#if BFD_SUPPORTS_PLUGINS
|
||||
bfd_plugin_set_program_name (program_name);
|
||||
#endif
|
||||
|
||||
expandargv (&argc, &argv);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user