diff options
Diffstat (limited to 'binutils')
-rw-r--r-- | binutils/ar.c | 4 | ||||
-rw-r--r-- | binutils/configure.ac | 6 | ||||
-rw-r--r-- | binutils/nm.c | 14 | ||||
-rw-r--r-- | binutils/objcopy.c | 60 |
4 files changed, 55 insertions, 29 deletions
diff --git a/binutils/ar.c b/binutils/ar.c index de41c9e..3cac3f3 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/configure.ac b/binutils/configure.ac index a393036..93e8a4b 100644 --- a/binutils/configure.ac +++ b/binutils/configure.ac @@ -201,9 +201,9 @@ GCC_AC_FUNC_MMAP AC_CHECK_FUNCS(fseeko fseeko64 getc_unlocked mkdtemp mkstemp utimensat utimes) AC_MSG_CHECKING([for mbstate_t]) -AC_TRY_COMPILE([#include <wchar.h>], -[mbstate_t teststate;], -have_mbstate_t=yes, have_mbstate_t=no) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <wchar.h>]], +[[mbstate_t teststate;]])], +[have_mbstate_t=yes],[have_mbstate_t=no]) AC_MSG_RESULT($have_mbstate_t) if test x"$have_mbstate_t" = xyes; then AC_DEFINE(HAVE_MBSTATE_T,1,[Define if mbstate_t exists in wchar.h.]) diff --git a/binutils/nm.c b/binutils/nm.c index a5d5631..a7f0e9d 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) @@ -802,6 +803,9 @@ 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; @@ -1484,7 +1488,11 @@ 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_get_lto_type (abfd) == lto_slim_ir_object +#if BFD_SUPPORTS_PLUGINS + && !bfd_plugin_target_p (abfd->xvec) +#endif + ) { report_plugin_err = false; non_fatal (_("%s: plugin needed to handle lto object"), diff --git a/binutils/objcopy.c b/binutils/objcopy.c index 5774711..654d2b9 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. */ @@ -170,6 +171,8 @@ 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. */ @@ -3687,6 +3690,8 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, bool ok_object; const char *element_name; + this_element->is_strip_input = 1; + element_name = bfd_get_filename (this_element); /* PR binutils/17533: Do not allow directory traversal outside of the current directory tree by archive members. */ @@ -3745,11 +3750,10 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, #if BFD_SUPPORTS_PLUGINS /* Ignore plugin target if all LTO sections should be removed. */ - ok_object = bfd_check_format_lto (this_element, bfd_object, - lto_sections_removed); -#else - ok_object = bfd_check_format (this_element, bfd_object); + 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 containing multiple target types. */ @@ -3768,7 +3772,9 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, #if BFD_SUPPORTS_PLUGINS /* Copy LTO IR file as unknown object. */ - if (bfd_plugin_target_p (this_element->xvec)) + if ((!lto_sections_removed + && this_element->lto_type == lto_slim_ir_object) + || bfd_plugin_target_p (this_element->xvec)) ok_object = false; else #endif @@ -3863,6 +3869,25 @@ copy_archive (bfd *ibfd, bfd *obfd, const char *output_target, return ok; } +static bool +check_format_object (bfd *ibfd, char ***obj_matching, + bool no_plugins ATTRIBUTE_UNUSED) +{ +#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. */ + if (no_plugins && ibfd->plugin_format == bfd_plugin_unknown) + { + ibfd->plugin_format = bfd_plugin_no; + if (bfd_check_format_matches (ibfd, bfd_object, obj_matching)) + return true; + ibfd->plugin_format = bfd_plugin_unknown; + } +#endif + return bfd_check_format_matches (ibfd, bfd_object, obj_matching); +} + /* The top-level control. */ static void @@ -3946,6 +3971,8 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, break; } + ibfd->is_strip_input = 1; + if (bfd_check_format (ibfd, bfd_archive)) { bool force_output_target; @@ -3988,21 +4015,7 @@ copy_file (const char *input_filename, const char *output_filename, int ofd, input_arch, target_defaulted)) status = 1; } - else if ( -#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. */ - bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching, - lto_sections_removed) - || (lto_sections_removed - && bfd_check_format_matches_lto (ibfd, bfd_object, - &obj_matching, false)) -#else - bfd_check_format_matches_lto (ibfd, bfd_object, &obj_matching, - false) -#endif - ) + else if (check_format_object (ibfd, &obj_matching, lto_sections_removed)) { bfd *obfd; do_copy: @@ -5066,6 +5079,11 @@ strip_main (int argc, char *argv[]) SECTION_CONTEXT_REMOVE) || !!find_section_list (".llvm.lto", false, SECTION_CONTEXT_REMOVE)); + /* NB: Must keep .gnu.debuglto_* sections unless all GCC LTO sections + will be removed to avoid undefined references to symbols in GCC LTO + debug sections. */ + if (!lto_sections_removed) + find_section_list (".gnu.debuglto_*", true, SECTION_CONTEXT_KEEP); #endif i = optind; |