[PATCH] libbfd: Always compile plugin.c into libbfd
H.J. Lu
hjl.tools@gmail.com
Wed Aug 6 18:21:57 GMT 2025
More information about the Binutils mailing list
Wed Aug 6 18:21:57 GMT 2025
- Previous message (by thread): [PATCH v1] aarch64 tests: remove irrelevant information messages from error tests
- Next message (by thread): [PATCH] libbfd: Always compile plugin.c into libbfd
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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> --- bfd/Makefile.am | 8 +++--- bfd/Makefile.in | 12 ++++---- bfd/archive.c | 6 ---- bfd/bfd-in.h | 2 -- bfd/bfd-in2.h | 8 ++++-- bfd/config.in | 3 ++ bfd/configure | 14 +++++----- bfd/configure.ac | 8 ++---- bfd/elflink.c | 7 +---- bfd/format.c | 18 ++---------- bfd/libbfd.h | 3 +- bfd/plugin.c | 26 ++++++++++++++++-- bfd/targets.c | 3 +- bfd/xtensa-dynconfig.c | 62 +++++++++++++++++++++--------------------- binutils/ar.c | 56 +++++++++++++++----------------------- binutils/arsup.c | 8 ------ binutils/nm.c | 24 ++++------------ binutils/objcopy.c | 35 ++++-------------------- ld/ldfile.c | 8 ------ ld/ldlang.c | 28 ++----------------- ld/ldlang.h | 2 -- ld/ldlex.h | 2 -- ld/ldmain.c | 8 ------ ld/lexsup.c | 27 ++++++++---------- ld/libdep_plugin.c | 2 -- ld/plugin.c | 2 -- ld/testplug.c | 2 -- ld/testplug2.c | 2 -- ld/testplug3.c | 2 -- ld/testplug4.c | 2 -- 30 files changed, 135 insertions(+), 255 deletions(-) diff --git a/bfd/Makefile.am b/bfd/Makefile.am index 3c3243269f1..02532fce686 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -79,7 +79,7 @@ BFD32_LIBS = \ coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \ hash.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \ section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \ - binary.lo ihex.lo srec.lo tekhex.lo verilog.lo + binary.lo ihex.lo srec.lo tekhex.lo verilog.lo plugin.lo BFD64_LIBS = archive64.lo @@ -88,7 +88,7 @@ BFD32_LIBS_CFILES = \ compress.c corefile.c elf-properties.c format.c hash.c \ libbfd.c linker.c merge.c opncls.c reloc.c \ section.c simple.c stab-syms.c stabs.c syms.c targets.c \ - binary.c ihex.c srec.c tekhex.c verilog.c + binary.c ihex.c srec.c tekhex.c verilog.c plugin.c BFD64_LIBS_CFILES = archive64.c @@ -924,11 +924,11 @@ stmp-bfd-h: bfd-in3.h BFD_H_FILES = bfd-in.h libbfd.c hash.c section.c syms.c \ archive.c archures.c bfd.c bfdio.c \ cache.c compress.c corefile.c format.c linker.c opncls.c \ - reloc.c simple.c stab-syms.c stabs.c targets.c + reloc.c simple.c stab-syms.c stabs.c targets.c plugin.c BFD64_H_FILES = archive64.c LIBBFD_H_FILES = libbfd-in.h libbfd.c bfd.c bfdio.c \ archive.c archures.c cache.c hash.c linker.c opncls.c \ - reloc.c section.c stabs.c targets.c + reloc.c section.c stabs.c targets.c plugin.c LIBCOFF_H_FILES = libcoff-in.h coffcode.h headers: stmp-bin2-h stmp-lbfd-h stmp-lcoff-h diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 4c259682fd0..bf9812dd212 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -182,7 +182,8 @@ am__objects_1 = archive.lo archures.lo bfd.lo bfdio.lo cache.lo \ coff-bfd.lo compress.lo corefile.lo elf-properties.lo \ format.lo hash.lo libbfd.lo linker.lo merge.lo opncls.lo \ reloc.lo section.lo simple.lo stab-syms.lo stabs.lo syms.lo \ - targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo + targets.lo binary.lo ihex.lo srec.lo tekhex.lo verilog.lo \ + plugin.lo am_libbfd_la_OBJECTS = $(am__objects_1) libbfd_la_OBJECTS = $(am_libbfd_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) @@ -481,7 +482,6 @@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ -supports_plugins = @supports_plugins@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ @@ -545,7 +545,7 @@ BFD32_LIBS = \ coff-bfd.lo compress.lo corefile.lo elf-properties.lo format.lo \ hash.lo libbfd.lo linker.lo merge.lo opncls.lo reloc.lo \ section.lo simple.lo stab-syms.lo stabs.lo syms.lo targets.lo \ - binary.lo ihex.lo srec.lo tekhex.lo verilog.lo + binary.lo ihex.lo srec.lo tekhex.lo verilog.lo plugin.lo BFD64_LIBS = archive64.lo BFD32_LIBS_CFILES = \ @@ -553,7 +553,7 @@ BFD32_LIBS_CFILES = \ compress.c corefile.c elf-properties.c format.c hash.c \ libbfd.c linker.c merge.c opncls.c reloc.c \ section.c simple.c stab-syms.c stabs.c syms.c targets.c \ - binary.c ihex.c srec.c tekhex.c verilog.c + binary.c ihex.c srec.c tekhex.c verilog.c plugin.c BFD64_LIBS_CFILES = archive64.c @@ -1214,12 +1214,12 @@ libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB) $(ZSTD_LIBS) .. BFD_H_FILES = bfd-in.h libbfd.c hash.c section.c syms.c \ archive.c archures.c bfd.c bfdio.c \ cache.c compress.c corefile.c format.c linker.c opncls.c \ - reloc.c simple.c stab-syms.c stabs.c targets.c + reloc.c simple.c stab-syms.c stabs.c targets.c plugin.c BFD64_H_FILES = archive64.c LIBBFD_H_FILES = libbfd-in.h libbfd.c bfd.c bfdio.c \ archive.c archures.c cache.c hash.c linker.c opncls.c \ - reloc.c section.c stabs.c targets.c + reloc.c section.c stabs.c targets.c plugin.c LIBCOFF_H_FILES = libcoff-in.h coffcode.h diff --git a/bfd/archive.c b/bfd/archive.c index 697b2ed23f2..179514f6f75 100644 --- a/bfd/archive.c +++ b/bfd/archive.c @@ -141,10 +141,8 @@ SUBSECTION #include "hashtab.h" #include "filenames.h" #include "bfdlink.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include "plugin.h" -#endif #ifndef errno extern int errno; @@ -2347,9 +2345,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) long src_count; if (bfd_get_lto_type (current) == lto_slim_ir_object -#if BFD_SUPPORTS_PLUGINS && !bfd_plugin_target_p (current->xvec) -#endif && report_plugin_err) { report_plugin_err = false; @@ -2407,9 +2403,7 @@ _bfd_compute_and_write_armap (bfd *arch, unsigned int elength) if (bfd_lto_slim_symbol_p (current, syms[src_count]->name) -#if BFD_SUPPORTS_PLUGINS && !bfd_plugin_target_p (current->xvec) -#endif && report_plugin_err) { report_plugin_err = false; diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index df5568e9639..e6860e59adf 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -60,8 +60,6 @@ extern "C" { is error prone, so using this macro is safer. */ #define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1) -#define BFD_SUPPORTS_PLUGINS @supports_plugins@ - /* The word size used by BFD on the host. This may be 64 with a 32 bit target if the host is 64 bit, or if other 64 bit targets have been selected with --enable-targets, or if --enable-64-bit-bfd. */ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 12512a3962c..30f49901226 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -2,7 +2,8 @@ generated from "bfd-in.h", "libbfd.c", "hash.c", "section.c", "syms.c", "archive.c", "archures.c", "bfd.c", "bfdio.c", "cache.c", "compress.c", "corefile.c", "format.c", "linker.c", "opncls.c", - "reloc.c", "simple.c", "stab-syms.c", "stabs.c" and "targets.c". + "reloc.c", "simple.c", "stab-syms.c", "stabs.c", "targets.c" + and "plugin.c". Run "make headers" in your build bfd/ to regenerate. */ /* Main header file for the bfd library -- portable access to object files. @@ -67,8 +68,6 @@ extern "C" { is error prone, so using this macro is safer. */ #define STRING_COMMA_LEN(STR) (STR), (sizeof (STR) - 1) -#define BFD_SUPPORTS_PLUGINS @supports_plugins@ - /* The word size used by BFD on the host. This may be 64 with a 32 bit target if the host is 64 bit, or if other 64 bit targets have been selected with --enable-targets, or if --enable-64-bit-bfd. */ @@ -8035,6 +8034,9 @@ const bfd_target *bfd_iterate_over_targets const char *bfd_flavour_name (enum bfd_flavour flavour); +/* Extracted from plugin.c. */ +bool bfd_plugin_enabled (void); + #ifdef __cplusplus } #endif diff --git a/bfd/config.in b/bfd/config.in index 7458362922c..ff053e30993 100644 --- a/bfd/config.in +++ b/bfd/config.in @@ -10,6 +10,9 @@ /* Define if building universal (internal helper macro) */ #undef AC_APPLE_UNIVERSAL_BUILD +/* Non-zero if BFD supports plugins. */ +#undef BFD_SUPPORTS_PLUGINS + /* Name of host specific core header file to include in elf.c. */ #undef CORE_HEADER diff --git a/bfd/configure b/bfd/configure index 28ac5ccfbe5..a16ddc73855 100755 --- a/bfd/configure +++ b/bfd/configure @@ -638,7 +638,6 @@ LIBOBJS bfd_ufile_ptr bfd_file_ptr lt_cv_dlopen_libs -supports_plugins COREFLAG COREFILE havevecs @@ -11153,7 +11152,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11156 "configure" +#line 11155 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11259,7 +11258,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11262 "configure" +#line 11261 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -15773,10 +15772,6 @@ do fi done -if test "$plugins" = "yes"; then - tb="$tb plugin.lo" -fi - # Target architecture .o files. # A couple of CPUs use shorter file names to avoid problems on DOS # filesystems. @@ -16851,6 +16846,11 @@ else supports_plugins=0 fi +cat >>confdefs.h <<_ACEOF +#define BFD_SUPPORTS_PLUGINS $supports_plugins +_ACEOF + + # Determine the host dependent file_ptr a.k.a. off_t type. In order diff --git a/bfd/configure.ac b/bfd/configure.ac index 502c526b606..d27c6577591 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -697,10 +697,6 @@ do fi done -if test "$plugins" = "yes"; then - tb="$tb plugin.lo" -fi - # Target architecture .o files. # A couple of CPUs use shorter file names to avoid problems on DOS # filesystems. @@ -1004,7 +1000,9 @@ if test "$plugins" = "yes"; then else supports_plugins=0 fi -AC_SUBST(supports_plugins) +AC_DEFINE_UNQUOTED(BFD_SUPPORTS_PLUGINS, $supports_plugins, + [Non-zero if BFD supports plugins.]) + AC_SUBST(lt_cv_dlopen_libs) # Determine the host dependent file_ptr a.k.a. off_t type. In order diff --git a/bfd/elflink.c b/bfd/elflink.c index c4f57cf2f3c..3009c5da292 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -27,10 +27,8 @@ #include "safe-ctype.h" #include "libiberty.h" #include "objalloc.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include "plugin.h" -#endif #include <limits.h> #ifndef CHAR_BIT @@ -3679,11 +3677,8 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef) get the correct symbol table. */ if (abfd->plugin_format == bfd_plugin_yes || abfd->plugin_format == bfd_plugin_yes_unused -#if BFD_SUPPORTS_PLUGINS || (abfd->plugin_format == bfd_plugin_unknown - && bfd_link_plugin_object_p (abfd)) -#endif - ) + && bfd_link_plugin_object_p (abfd))) { /* Use the IR symbol table if the object has been claimed by plugin. */ diff --git a/bfd/format.c b/bfd/format.c index bd9fa8d6c33..a0033005045 100644 --- a/bfd/format.c +++ b/bfd/format.c @@ -46,10 +46,8 @@ SUBSECTION #include "sysdep.h" #include "bfd.h" #include "libbfd.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include "plugin.h" -#endif /* IMPORT from targets.c. */ extern const size_t _bfd_target_vector_entries; @@ -367,9 +365,8 @@ struct lto_section /* Set lto_type in ABFD. */ static void -bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED) +bfd_set_lto_type (bfd *abfd) { -#if BFD_SUPPORTS_PLUGINS if (abfd->format == bfd_object && abfd->lto_type == lto_non_object && (abfd->flags @@ -407,7 +404,6 @@ bfd_set_lto_type (bfd *abfd ATTRIBUTE_UNUSED) abfd->lto_type = type; } -#endif } /* @@ -501,11 +497,8 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) /* If the target type was explicitly specified, just check that target. */ fail_targ = NULL; if (!abfd->target_defaulted -#if BFD_SUPPORTS_PLUGINS && !(abfd->plugin_format == bfd_plugin_no - && bfd_plugin_target_p (save_targ)) -#endif - ) + && bfd_plugin_target_p (save_targ))) { if (bfd_seek (abfd, 0, SEEK_SET) != 0) /* rewind! */ goto err_ret; @@ -519,12 +512,10 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) standalone fat IR object, it will be copied as non-IR object. */ if (cleanup -#if BFD_SUPPORTS_PLUGINS && (!abfd->is_strip_input || !bfd_plugin_target_p (abfd->xvec) || (abfd->lto_type != lto_fat_ir_object && abfd->my_archive == NULL)) -#endif ) goto ok_ret; @@ -571,12 +562,9 @@ bfd_check_format_matches (bfd *abfd, bfd_format format, char ***matching) bfd_plugin_get_symbols_in_object_only.) */ if (*target == &binary_vec || *target == fail_targ -#if BFD_SUPPORTS_PLUGINS || (((abfd->is_linker_input && match_count != 0) || abfd->plugin_format == bfd_plugin_no) - && bfd_plugin_target_p (*target)) -#endif - ) + && bfd_plugin_target_p (*target))) continue; /* If we already tried a match, the bfd is modified and may diff --git a/bfd/libbfd.h b/bfd/libbfd.h index bab1f71f7e3..c67854eaab5 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -1,7 +1,7 @@ /* DO NOT EDIT! -*- buffer-read-only: t -*- This file is automatically generated from "libbfd-in.h", "libbfd.c", "bfd.c", "bfdio.c", "archive.c", "archures.c", "cache.c", "hash.c", "linker.c", "opncls.c", - "reloc.c", "section.c", "stabs.c" and "targets.c". + "reloc.c", "section.c", "stabs.c", "targets.c" and "plugin.c". Run "make headers" in your build bfd/ to regenerate. */ /* libbfd.h -- Declarations used by bfd library *implementation*. @@ -3719,6 +3719,7 @@ bool _bfd_write_stab_strings (bfd *, struct stab_info *) ATTRIBUTE_HIDDEN; bfd_vma _bfd_stab_section_offset (asection *, void *, bfd_vma) ATTRIBUTE_HIDDEN; /* Extracted from targets.c. */ +/* Extracted from plugin.c. */ #ifdef __cplusplus } #endif diff --git a/bfd/plugin.c b/bfd/plugin.c index 43ca444e7a1..7f544446fd2 100644 --- a/bfd/plugin.c +++ b/bfd/plugin.c @@ -21,7 +21,7 @@ #include "sysdep.h" #include "bfd.h" -#if BFD_SUPPORTS_PLUGINS +#define PLUGIN_ENABLED (!!BFD_SUPPORTS_PLUGINS) #include <assert.h> #ifdef HAVE_DLFCN_H @@ -38,6 +38,23 @@ #include "libiberty.h" #include <dirent.h> +/* +FUNCTION + bfd_plugin_enabled + +SYNOPSIS + bool bfd_plugin_enabled (void); + +DESCRIPTION + Return true if plugin is enabled. +*/ + +bool +bfd_plugin_enabled (void) +{ + return PLUGIN_ENABLED; +} + #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) #define RTLD_NOW 0 /* Dummy value. */ @@ -143,7 +160,8 @@ static const char *plugin_program_name; void bfd_plugin_set_program_name (const char *program_name) { - plugin_program_name = program_name; + if (PLUGIN_ENABLED) + plugin_program_name = program_name; } static struct plugin_list_entry *plugin_list = NULL; @@ -755,6 +773,9 @@ load_plugin (bfd *abfd) static bfd_cleanup bfd_plugin_object_p (bfd *abfd) { + if (!PLUGIN_ENABLED) + return NULL; + /* Since ld_plugin_object_p is called only for linker command-line input objects, pass true to ld_plugin_object_p so that the same input IR file won't be included twice if the LDPT_REGISTER_CLAIM_FILE_HOOK_V2 @@ -1029,4 +1050,3 @@ const bfd_target plugin_vec = NULL /* backend_data. */ }; -#endif /* BFD_SUPPORTS_PLUGINS */ diff --git a/bfd/targets.c b/bfd/targets.c index c2ee9179f37..a6d8def9a1e 100644 --- a/bfd/targets.c +++ b/bfd/targets.c @@ -1382,9 +1382,8 @@ static const bfd_target * const _bfd_target_vector[] = /* Likewise for ihex. */ &ihex_vec, -#if BFD_SUPPORTS_PLUGINS +/* Always include plugin. */ &plugin_vec, -#endif /* Add any required traditional-core-file-handler. */ diff --git a/bfd/xtensa-dynconfig.c b/bfd/xtensa-dynconfig.c index 89053f7976a..eb04b9d7e88 100644 --- a/bfd/xtensa-dynconfig.c +++ b/bfd/xtensa-dynconfig.c @@ -69,43 +69,44 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, const void *no_name_def ATTRIBUTE_UNUSED) { static int init; -#if BFD_SUPPORTS_PLUGINS - static void *handle; - void *p; - - if (!init) + if (bfd_plugin_enabled ()) { - const char *path = getenv (CONFIG_ENV_NAME); + static void *handle; + void *p; - init = 1; - if (!path) - return no_plugin_def; - handle = dlopen (path, RTLD_LAZY); - if (!handle) + if (!init) { - _bfd_error_handler (_("%s is defined but could not be loaded: %s"), - CONFIG_ENV_NAME, dlerror ()); - abort (); + const char *path = getenv (CONFIG_ENV_NAME); + + init = 1; + if (!path) + return no_plugin_def; + handle = dlopen (path, RTLD_LAZY); + if (!handle) + { + _bfd_error_handler (_("%s is defined but could not be loaded: %s"), + CONFIG_ENV_NAME, dlerror ()); + abort (); + } + } + else if (!handle) + { + return no_plugin_def; } - } - else if (!handle) - { - return no_plugin_def; - } - p = dlsym (handle, name); - if (!p) - { - if (no_name_def) - return no_name_def; + p = dlsym (handle, name); + if (!p) + { + if (no_name_def) + return no_name_def; - _bfd_error_handler (_("%s is loaded but symbol \"%s\" is not found: %s"), - CONFIG_ENV_NAME, name, dlerror ()); - abort (); + _bfd_error_handler (_("%s is loaded but symbol \"%s\" is not found: %s"), + CONFIG_ENV_NAME, name, dlerror ()); + abort (); + } + return p; } - return p; -#else - if (!init) + else if (!init) { const char *path = getenv (CONFIG_ENV_NAME); @@ -118,7 +119,6 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED, } } return no_plugin_def; -#endif } XTENSA_CONFIG_INSTANCE_LIST; diff --git a/binutils/ar.c b/binutils/ar.c index de41c9e3dd1..6d5c7b297a2 100644 --- a/binutils/ar.c +++ b/binutils/ar.c @@ -148,11 +148,7 @@ static int show_version = 0; static int show_help = 0; -#if BFD_SUPPORTS_PLUGINS static const char *plugin_target = "plugin"; -#else -static const char *plugin_target = NULL; -#endif static const char *target = NULL; @@ -280,18 +276,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); @@ -343,10 +339,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); @@ -370,10 +367,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\ @@ -600,12 +596,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; @@ -675,12 +668,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; } } @@ -731,9 +721,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); diff --git a/binutils/arsup.c b/binutils/arsup.c index 67cbd5c2835..3051ca39d6e 100644 --- a/binutils/arsup.c +++ b/binutils/arsup.c @@ -180,11 +180,7 @@ ar_open (char *name, int t) bfd *element; bfd *ibfd; -#if BFD_SUPPORTS_PLUGINS ibfd = bfd_openr (name, "plugin"); -#else - ibfd = bfd_openr (name, NULL); -#endif if (!ibfd) { @@ -266,11 +262,7 @@ ar_addmod (struct list *list) { bfd *abfd; -#if BFD_SUPPORTS_PLUGINS abfd = bfd_openr (list->name, "plugin"); -#else - abfd = bfd_openr (list->name, NULL); -#endif if (!abfd) { fprintf (stderr, _("%s: can't open file %s\n"), diff --git a/binutils/nm.c b/binutils/nm.c index d44083dcc94..a224997951e 100644 --- a/binutils/nm.c +++ b/binutils/nm.c @@ -221,11 +221,7 @@ static char other_format[] = "%02x"; static char desc_format[] = "%04x"; static char *target = NULL; -#if BFD_SUPPORTS_PLUGINS static const char *plugin_target = "plugin"; -#else -static const char *plugin_target = NULL; -#endif typedef enum unicode_display_type { @@ -343,10 +339,9 @@ usage (FILE *stream, int status) -P, --portability Same as --format=posix\n")); fprintf (stream, _("\ -r, --reverse-sort Reverse the sense of the sort\n")); -#if BFD_SUPPORTS_PLUGINS - fprintf (stream, _("\ + if (bfd_plugin_enabled ()) + fprintf (stream, _("\ --plugin NAME Load the specified plugin\n")); -#endif fprintf (stream, _("\ -S, --print-size Print size of defined symbols\n")); fprintf (stream, _("\ @@ -802,9 +797,7 @@ filter_symbols (bfd *abfd, bool is_dynamic, void *minisyms, continue; if (bfd_lto_slim_symbol_p (abfd, sym->name) -#if BFD_SUPPORTS_PLUGINS && !bfd_plugin_target_p (abfd->xvec) -#endif && report_plugin_err) { report_plugin_err = false; @@ -1488,10 +1481,7 @@ display_rel_file (bfd *abfd, bfd *archive_bfd) /* lto_type is set to lto_non_ir_object when a bfd is loaded with a compiler LTO plugin. */ if (bfd_get_lto_type (abfd) == lto_slim_ir_object -#if BFD_SUPPORTS_PLUGINS - && !bfd_plugin_target_p (abfd->xvec) -#endif - ) + && !bfd_plugin_target_p (abfd->xvec)) { report_plugin_err = false; non_fatal (_("%s: plugin needed to handle lto object"), @@ -1992,9 +1982,7 @@ main (int argc, char **argv) program_name = *argv; 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); @@ -2141,11 +2129,9 @@ main (int argc, char **argv) break; case OPTION_PLUGIN: /* --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 - fatal (_("sorry - this program has been built without plugin support\n")); -#endif break; case OPTION_IFUNC_CHARS: diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 3404bec1d08..232730c0a8d 100644 --- a/binutils/objcopy.c +++ b/binutils/objcopy.c @@ -167,12 +167,8 @@ static struct section_list *change_sections; /* TRUE if some sections are to be removed. */ static bool sections_removed; -#if BFD_SUPPORTS_PLUGINS /* TRUE if all GCC LTO sections are to be removed. */ static bool lto_sections_removed; -#else -#define lto_sections_removed false -#endif /* TRUE if only some sections are to be copied. */ static bool sections_copied; @@ -769,10 +765,9 @@ strip_usage (FILE *stream, int exit_status) --info List object formats & architectures supported\n\ -o <file> Place stripped output into <file>\n\ ")); -#if BFD_SUPPORTS_PLUGINS - fprintf (stream, _("\ + if (bfd_plugin_enabled ()) + fprintf (stream, _("\ --plugin NAME Load the specified plugin\n")); -#endif list_supported_targets (program_name, stream); if (REPORT_BUGS_TO[0] && exit_status == 0) @@ -3747,11 +3742,9 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, l->obfd = NULL; list = l; -#if BFD_SUPPORTS_PLUGINS /* Ignore plugin target if all LTO sections should be removed. */ if (lto_sections_removed) this_element->plugin_format = bfd_plugin_no; -#endif ok_object = bfd_check_format (this_element, bfd_object); /* PR binutils/3110: Cope with archives @@ -3769,15 +3762,12 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, goto cleanup_and_exit; } -#if BFD_SUPPORTS_PLUGINS /* Copy LTO IR file as unknown object. */ if ((!lto_sections_removed && this_element->lto_type == lto_slim_ir_object) || bfd_plugin_target_p (this_element->xvec)) ok_object = false; - else -#endif - if (ok_object) + else if (ok_object) { ok = copy_object (this_element, output_element, input_arch, target_defaulted); @@ -3869,10 +3859,8 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, } static bool -check_format_object (bfd *ibfd, char ***obj_matching, - bool no_plugins ATTRIBUTE_UNUSED) +check_format_object (bfd *ibfd, char ***obj_matching, bool no_plugins) { -#if BFD_SUPPORTS_PLUGINS /* Ignore plugin target first if all LTO sections should be removed. Try with plugin target next if ignoring plugin target fails to match the format. */ @@ -3883,7 +3871,6 @@ check_format_object (bfd *ibfd, char ***obj_matching, return true; ibfd->plugin_format = bfd_plugin_unknown; } -#endif return bfd_check_format_matches (ibfd, bfd_object, obj_matching); } @@ -3911,11 +3898,9 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, return; } -#if BFD_SUPPORTS_PLUGINS /* Enable LTO plugin in strip. */ if (is_strip && !target) target = "plugin"; -#endif /* To allow us to do "strip *" without dying on the first non-object file, failures are nonfatal. */ @@ -4040,7 +4025,6 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, return; } -#if BFD_SUPPORTS_PLUGINS if (bfd_plugin_target_p (ibfd->xvec)) { /* Copy LTO IR file as unknown file. */ @@ -4051,7 +4035,6 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, status = 1; } else -#endif { if (! copy_object (ibfd, obfd, input_arch, target_defaulted)) status = 1; @@ -4923,9 +4906,7 @@ strip_main (int argc, char *argv[]) char *output_file = NULL; bool merge_notes_set = false; -#if BFD_SUPPORTS_PLUGINS bfd_plugin_set_program_name (argv[0]); -#endif while ((c = getopt_long (argc, argv, "I:O:F:K:MN:R:o:sSpdgxXHhVvwDU", strip_options, (int *) 0)) != EOF) @@ -5018,11 +4999,9 @@ strip_main (int argc, char *argv[]) keep_section_symbols = true; break; case OPTION_PLUGIN: /* --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 - fatal (_("sorry - this program has been built without plugin support\n")); -#endif break; case 0: /* We've been given a long option. */ @@ -5068,7 +5047,6 @@ strip_main (int argc, char *argv[]) if (output_target == NULL) output_target = input_target; -#if BFD_SUPPORTS_PLUGINS /* Check if all GCC LTO sections should be removed, assuming all LTO sections will be removed with -R .gnu.lto_.*. * Remove .gnu.lto_.* sections will also remove .gnu.debuglto_. sections. LLVM IR @@ -5083,7 +5061,6 @@ strip_main (int argc, char *argv[]) debug sections. */ if (!lto_sections_removed) find_section_list (".gnu.debuglto_*", true, SECTION_CONTEXT_KEEP); -#endif i = optind; if (i == argc diff --git a/ld/ldfile.c b/ld/ldfile.c index 75fd360d5e3..10b06353b69 100644 --- a/ld/ldfile.c +++ b/ld/ldfile.c @@ -35,10 +35,8 @@ #include "libiberty.h" #include "filenames.h" #include <fnmatch.h> -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include "plugin.h" -#endif /* BFD_SUPPORTS_PLUGINS */ bool ldfile_assumed_script = false; const char *ldfile_output_machine_name = ""; @@ -366,9 +364,7 @@ ldfile_try_open_bfd (const char *attempt, } /* PR 30568: Do not track lto generated temporary object files. */ -#if BFD_SUPPORTS_PLUGINS if (!entry->flags.lto_output) -#endif track_dependency_files (attempt); /* Linker needs to decompress sections. */ @@ -377,10 +373,8 @@ ldfile_try_open_bfd (const char *attempt, /* This is a linker input BFD. */ entry->the_bfd->is_linker_input = 1; -#if BFD_SUPPORTS_PLUGINS if (entry->flags.lto_output) entry->the_bfd->lto_output = 1; -#endif /* If we are searching for this file, see if the architecture is compatible with the output file. If it isn't, keep searching. @@ -518,7 +512,6 @@ ldfile_try_open_bfd (const char *attempt, } } success: -#if BFD_SUPPORTS_PLUGINS /* If plugins are active, they get first chance to claim any successfully-opened input file. We skip archives here; the plugin wants us to offer it the individual @@ -534,7 +527,6 @@ ldfile_try_open_bfd (const char *attempt, plugin_maybe_claim (entry); else cmdline_check_object_only_section (entry->the_bfd, false); -#endif /* BFD_SUPPORTS_PLUGINS */ /* It opened OK, the format checked out, and the plugins have had their chance to claim it, so this is success. */ diff --git a/ld/ldlang.c b/ld/ldlang.c index 6e31c359c9d..fc7dc9976aa 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -45,9 +45,7 @@ #include "bfdver.h" #include <errno.h> -#if BFD_SUPPORTS_PLUGINS #include "plugin.h" -#endif /* FIXME: Put it here to avoid NAME conflict from ldgram.h. */ #include "elf-bfd.h" @@ -3630,10 +3628,8 @@ enum open_bfd_mode OPEN_BFD_FORCE = 1, OPEN_BFD_RESCAN = 2 }; -#if BFD_SUPPORTS_PLUGINS static lang_input_statement_type *plugin_insert = NULL; static struct bfd_link_hash_entry *plugin_undefs = NULL; -#endif static void open_input_bfds (lang_statement_union_type *s, @@ -3663,9 +3659,7 @@ open_input_bfds (lang_statement_union_type *s, case lang_group_statement_enum: { struct bfd_link_hash_entry *undefs; -#if BFD_SUPPORTS_PLUGINS lang_input_statement_type *plugin_insert_save; -#endif /* We must continually search the entries in the group until no new symbols are added to the list of undefined @@ -3673,21 +3667,16 @@ open_input_bfds (lang_statement_union_type *s, do { -#if BFD_SUPPORTS_PLUGINS plugin_insert_save = plugin_insert; -#endif undefs = link_info.hash->undefs_tail; open_input_bfds (s->group_statement.children.head, os, mode | OPEN_BFD_FORCE); } while (undefs != link_info.hash->undefs_tail -#if BFD_SUPPORTS_PLUGINS /* Objects inserted by a plugin, which are loaded before we hit this loop, may have added new undefs. */ - || (plugin_insert != plugin_insert_save && plugin_undefs) -#endif - ); + || (plugin_insert != plugin_insert_save && plugin_undefs)); } break; case lang_target_statement_enum: @@ -3708,10 +3697,8 @@ open_input_bfds (lang_statement_union_type *s, has been loaded already. Do the same for a rescan. Likewise reload --as-needed shared libs. */ if (mode != OPEN_BFD_NORMAL -#if BFD_SUPPORTS_PLUGINS && ((mode & OPEN_BFD_RESCAN) == 0 || plugin_insert == NULL) -#endif && s->input_statement.flags.loaded && (abfd = s->input_statement.the_bfd) != NULL && ((bfd_get_format (abfd) == bfd_archive @@ -3755,12 +3742,10 @@ open_input_bfds (lang_statement_union_type *s, } } } -#if BFD_SUPPORTS_PLUGINS /* If we have found the point at which a plugin added new files, clear plugin_insert to enable archive rescan. */ if (&s->input_statement == plugin_insert) plugin_insert = NULL; -#endif break; case lang_assignment_statement_enum: if (s->assignment_statement.exp->type.node_class != etree_assert) @@ -7346,11 +7331,9 @@ lang_check (void) file != NULL; file = file->next) { -#if BFD_SUPPORTS_PLUGINS /* Don't check format of files claimed by plugin. */ if (file->flags.claimed) continue; -#endif /* BFD_SUPPORTS_PLUGINS */ input_bfd = file->the_bfd; compatible = bfd_arch_get_compatible (input_bfd, link_info.output_bfd, @@ -7877,10 +7860,8 @@ lang_gc_sections (void) LANG_FOR_EACH_INPUT_STATEMENT (f) { asection *sec; -#if BFD_SUPPORTS_PLUGINS if (f->flags.claimed) continue; -#endif for (sec = f->the_bfd->sections; sec != NULL; sec = sec->next) if ((sec->flags & SEC_DEBUGGING) == 0 || strcmp (sec->name, ".stabstr") != 0) @@ -8024,7 +8005,6 @@ lang_relax_sections (bool need_layout) } } -#if BFD_SUPPORTS_PLUGINS /* Find the insert point for the plugin's replacement files. We place them after the first claimed real object file, or if the first claimed object is an archive member, after the last real @@ -8152,7 +8132,6 @@ find_next_input_statement (lang_statement_union_type **s) } return s; } -#endif /* BFD_SUPPORTS_PLUGINS */ /* Insert SRCLIST into DESTLIST after given element by chaining on FIELD as the next-pointer. (Counterintuitively does not need @@ -8328,7 +8307,6 @@ lang_process (void) ldemul_before_plugin_all_symbols_read (); -#if BFD_SUPPORTS_PLUGINS if (link_info.lto_plugin_active) { lang_statement_list_type added; @@ -8439,9 +8417,7 @@ lang_process (void) } } } - else -#endif /* BFD_SUPPORTS_PLUGINS */ - if (bfd_link_relocatable (&link_info)) + else if (bfd_link_relocatable (&link_info)) { /* Check if .gnu_object_only section should be created. */ bfd *p; diff --git a/ld/ldlang.h b/ld/ldlang.h index 8d905f04742..a9607bef765 100644 --- a/ld/ldlang.h +++ b/ld/ldlang.h @@ -287,7 +287,6 @@ struct lang_input_statement_flags /* Set if reloading an archive or --as-needed lib. */ unsigned int reload : 1; -#if BFD_SUPPORTS_PLUGINS /* Set if the file was claimed by a plugin. */ unsigned int claimed : 1; @@ -296,7 +295,6 @@ struct lang_input_statement_flags /* Set if added by the lto plugin add_input_file callback. */ unsigned int lto_output : 1; -#endif /* BFD_SUPPORTS_PLUGINS */ /* Head of list of pushed flags. */ struct lang_input_statement_flags *pushed; diff --git a/ld/ldlex.h b/ld/ldlex.h index 815da76a4c0..d0c2e5d6db8 100644 --- a/ld/ldlex.h +++ b/ld/ldlex.h @@ -146,11 +146,9 @@ enum option_values OPTION_WARN_ALTERNATE_EM, OPTION_REDUCE_MEMORY_OVERHEADS, OPTION_MAX_CACHE_SIZE, -#if BFD_SUPPORTS_PLUGINS OPTION_PLUGIN, OPTION_PLUGIN_OPT, OPTION_PLUGIN_SAVE_TEMPS, -#endif /* BFD_SUPPORTS_PLUGINS */ OPTION_DEFAULT_SCRIPT, OPTION_PRINT_OUTPUT_FORMAT, OPTION_PRINT_SYSROOT, diff --git a/ld/ldmain.c b/ld/ldmain.c index 67c60c3f80d..2cf854973a2 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -40,10 +40,8 @@ #include "ldfile.h" #include "ldemul.h" #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. */ #if !defined(S_ISDIR) && defined(S_IFDIR) @@ -228,13 +226,11 @@ ld_cleanup (void) inext = ibfd->link.next; bfd_close_all_done (ibfd); } -#if BFD_SUPPORTS_PLUGINS /* Note - we do not call ld_plugin_start (PHASE_PLUGINS) here as this function is only called when the linker is exiting - ie after any stats may have been reported, and potentially in the middle of a phase where we have already started recording plugin stats. */ plugin_call_cleanup (); -#endif if (output_filename && delete_output_file_on_failure) unlink_if_ordinary (output_filename); } @@ -725,12 +721,10 @@ main (int argc, char **argv) ld_stop_phase (PHASE_PARSE); -#if BFD_SUPPORTS_PLUGINS ld_start_phase (PHASE_PLUGINS); /* Now all the plugin arguments have been gathered, we can load them. */ plugin_load_plugins (); ld_stop_phase (PHASE_PLUGINS); -#endif /* BFD_SUPPORTS_PLUGINS */ ld_start_phase (PHASE_PARSE); @@ -1308,7 +1302,6 @@ add_archive_element (struct bfd_link_info *info, (if enabled) may possibly alter it to point to a replacement BFD, but we still want to output the original BFD filename. */ orig_input = *input; -#if BFD_SUPPORTS_PLUGINS /* Don't claim a fat IR object if no IR object should be claimed. */ if (link_info.lto_plugin_active && (!no_more_claiming @@ -1337,7 +1330,6 @@ add_archive_element (struct bfd_link_info *info, } else cmdline_check_object_only_section (input->the_bfd, false); -#endif /* BFD_SUPPORTS_PLUGINS */ if (link_info.input_bfds_tail == &input->the_bfd->link.next || input->the_bfd->link.next != NULL) diff --git a/ld/lexsup.c b/ld/lexsup.c index bde20465835..5cb77992733 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -41,9 +41,7 @@ #include "ldver.h" #include "ldemul.h" #include "demangle.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin.h" -#endif /* BFD_SUPPORTS_PLUGINS */ #ifndef PATH_SEPARATOR #if defined (__MSDOS__) || (defined (_WIN32) && ! defined (__CYGWIN32__)) @@ -182,7 +180,6 @@ static const struct ld_option ld_options[] = 'O', NULL, N_("Optimize output file"), ONE_DASH }, { {"out-implib", required_argument, NULL, OPTION_OUT_IMPLIB}, '\0', N_("FILE"), N_("Generate import library"), TWO_DASHES }, -#if BFD_SUPPORTS_PLUGINS { {"plugin", required_argument, NULL, OPTION_PLUGIN}, '\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH }, { {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT}, @@ -196,12 +193,6 @@ static const struct ld_option ld_options[] = { {"flto-partition=", required_argument, NULL, OPTION_IGNORE}, '\0', NULL, N_("Ignored for GCC LTO option compatibility"), ONE_DASH }, -#else - { {"plugin", required_argument, NULL, OPTION_IGNORE}, - '\0', N_("PLUGIN"), N_("Load named plugin (ignored)"), ONE_DASH }, - { {"plugin-opt", required_argument, NULL, OPTION_IGNORE}, - '\0', N_("ARG"), N_("Send arg to last-loaded plugin (ignored)"), ONE_DASH }, -#endif /* BFD_SUPPORTS_PLUGINS */ { {"fuse-ld=", required_argument, NULL, OPTION_IGNORE}, '\0', NULL, N_("Ignored for GCC linker option compatibility"), ONE_DASH }, @@ -1213,18 +1204,18 @@ parse_args (unsigned argc, char **argv) case OPTION_PRINT_OUTPUT_FORMAT: command_line.print_output_format = true; break; -#if BFD_SUPPORTS_PLUGINS case OPTION_PLUGIN: - plugin_opt_plugin (optarg); + if (bfd_plugin_enabled ()) + plugin_opt_plugin (optarg); break; case OPTION_PLUGIN_OPT: - if (plugin_opt_plugin_arg (optarg)) + if (bfd_plugin_enabled () + && plugin_opt_plugin_arg (optarg)) fatal (_("%P: bad -plugin-opt option\n")); break; case OPTION_PLUGIN_SAVE_TEMPS: config.plugin_save_temps = true; break; -#endif /* BFD_SUPPORTS_PLUGINS */ case 'q': link_info.emitrelocations = true; break; @@ -1543,9 +1534,7 @@ parse_args (unsigned argc, char **argv) int level ATTRIBUTE_UNUSED = strtoul (optarg, &end, 0); if (*end) fatal (_("%P: invalid number `%s'\n"), optarg); -#if BFD_SUPPORTS_PLUGINS report_plugin_symbols = level > 1; -#endif /* BFD_SUPPORTS_PLUGINS */ } break; case 'v': @@ -2474,7 +2463,13 @@ help (void) for (; len < 30; len++) putchar (' '); - printf ("%s\n", _(ld_options[i].doc)); + printf ("%s", _(ld_options[i].doc)); + if ((ld_options[i].opt.val == OPTION_PLUGIN + || ld_options[i].opt.val == OPTION_PLUGIN_OPT) + && !bfd_plugin_enabled ()) + puts (_(" (ignored)")); + else + putchar ('\n'); } } printf (_(" @FILE")); diff --git a/ld/libdep_plugin.c b/ld/libdep_plugin.c index 605d5976aa3..e1dbf1895b2 100644 --- a/ld/libdep_plugin.c +++ b/ld/libdep_plugin.c @@ -20,7 +20,6 @@ #include "sysdep.h" #include "bfd.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include <ctype.h> /* For isspace. */ @@ -340,4 +339,3 @@ onload (struct ld_plugin_tv *tv) fflush (NULL); return LDPS_OK; } -#endif /* BFD_SUPPORTS_PLUGINS */ diff --git a/ld/plugin.c b/ld/plugin.c index dedd1a08b30..08d827c1ec7 100644 --- a/ld/plugin.c +++ b/ld/plugin.c @@ -21,7 +21,6 @@ #include "sysdep.h" #include "libiberty.h" #include "bfd.h" -#if BFD_SUPPORTS_PLUGINS #include "bfdlink.h" #include "bfdver.h" #include "ctf-api.h" @@ -1536,4 +1535,3 @@ plugin_notice (struct bfd_link_info *info, abfd, section, value, flags); return true; } -#endif /* BFD_SUPPORTS_PLUGINS */ diff --git a/ld/testplug.c b/ld/testplug.c index ffb7787e969..e5c3ec2055b 100644 --- a/ld/testplug.c +++ b/ld/testplug.c @@ -20,7 +20,6 @@ #include "sysdep.h" #include "bfd.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" /* For ARRAY_SIZE macro only - we don't link the library itself. */ #include "libiberty.h" @@ -673,4 +672,3 @@ oncleanup (void) fflush (NULL); return cleanup_ret; } -#endif /* BFD_SUPPORTS_PLUGINS */ diff --git a/ld/testplug2.c b/ld/testplug2.c index f7923831942..788d1930e3a 100644 --- a/ld/testplug2.c +++ b/ld/testplug2.c @@ -21,7 +21,6 @@ #include "sysdep.h" #include "bfd.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include "filenames.h" /* For ARRAY_SIZE macro only - we don't link the library itself. */ @@ -675,4 +674,3 @@ oncleanup (void) fflush (NULL); return cleanup_ret; } -#endif /* BFD_SUPPORTS_PLUGINS */ diff --git a/ld/testplug3.c b/ld/testplug3.c index 03735340af7..91a9661e8be 100644 --- a/ld/testplug3.c +++ b/ld/testplug3.c @@ -21,7 +21,6 @@ #include "sysdep.h" #include "bfd.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include "filenames.h" /* For ARRAY_SIZE macro only - we don't link the library itself. */ @@ -633,4 +632,3 @@ oncleanup (void) fflush (NULL); return cleanup_ret; } -#endif /* BFD_SUPPORTS_PLUGINS */ diff --git a/ld/testplug4.c b/ld/testplug4.c index 71eaf593ad3..21a2cd119d3 100644 --- a/ld/testplug4.c +++ b/ld/testplug4.c @@ -21,7 +21,6 @@ #include "sysdep.h" #include "bfd.h" -#if BFD_SUPPORTS_PLUGINS #include "plugin-api.h" #include "filenames.h" /* For ARRAY_SIZE macro only - we don't link the library itself. */ @@ -681,4 +680,3 @@ oncleanup (void) fflush (NULL); return cleanup_ret; } -#endif /* BFD_SUPPORTS_PLUGINS */ -- 2.50.1
- Previous message (by thread): [PATCH v1] aarch64 tests: remove irrelevant information messages from error tests
- Next message (by thread): [PATCH] libbfd: Always compile plugin.c into libbfd
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Binutils mailing list