case "${target}" in
- hppa*64*-*-*) ;;
*-*-*aout*| i[3-7]86-*-msdos* | ns32k-*-* | pdp11-*-*)
if test "$plugins" = "yes"; then
if test "${enable_plugins+set}" = set; then
plugins=no
fi
fi ;;
- hppa*-*-hpux* | *-*-*vms* | \
- powerpc*-*-aix* | powerpc-*-beos* | powerpc-*-macos* | rs6000-*-*)
- if test "$plugins" = "yes"; then
- if test "${enable_plugins+set}" = set; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Enabling plugins may result in ar creating non-standard archives for ${target}" >&5
-$as_echo "$as_me: WARNING: Enabling plugins may result in ar creating non-standard archives for ${target}" >&2;}
- else
- plugins=no
- fi
- fi ;;
esac
if test "$plugins" = "yes"; then
changequote(,)dnl
case "${target}" in
- hppa*64*-*-*) ;;
*-*-*aout*| i[3-7]86-*-msdos* | ns32k-*-* | pdp11-*-*)
changequote([,])dnl
if test "$plugins" = "yes"; then
plugins=no
fi
fi ;;
- hppa*-*-hpux* | *-*-*vms* | \
- powerpc*-*-aix* | powerpc-*-beos* | powerpc-*-macos* | rs6000-*-*)
- if test "$plugins" = "yes"; then
- if test "${enable_plugins+set}" = set; then
- AC_MSG_WARN(Enabling plugins may result in ar creating non-standard archives for ${target})
- else
- plugins=no
- fi
- fi ;;
esac
AM_CONDITIONAL(PLUGINS, test "$plugins" = "yes")
{ /* bfd_check_format. */
_bfd_dummy_target,
bfd_plugin_object_p,
- bfd_generic_archive_p,
+ _bfd_dummy_target,
_bfd_dummy_target
},
{ /* bfd_set_format. */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
- _bfd_generic_mkarchive,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
{ /* bfd_write_contents. */
_bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
- _bfd_write_archive_contents,
+ _bfd_bool_bfd_false_error,
_bfd_bool_bfd_false_error,
},
BFD_JUMP_TABLE_GENERIC (bfd_plugin),
BFD_JUMP_TABLE_COPY (bfd_plugin),
BFD_JUMP_TABLE_CORE (bfd_plugin),
-#ifdef USE_64_BIT_ARCHIVE
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_64_bit),
-#else
- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff),
-#endif
+ BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
BFD_JUMP_TABLE_SYMBOLS (bfd_plugin),
BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
BFD_JUMP_TABLE_WRITE (bfd_plugin),
#define EXT_NAME_LEN 6 /* Ditto for *NIX. */
#endif
-/* Static declarations. */
+/* Forward declarations. */
-static void mri_emul (void);
static const char *normalize (const char *, bfd *);
-static void remove_output (void);
-static void map_over_members (bfd *, void (*)(bfd *), char **, int);
static void print_contents (bfd * member);
static void delete_members (bfd *, char **files_to_delete);
static void write_archive (bfd *);
static int ranlib_only (const char *archname);
static int ranlib_touch (const char *archname);
-static void usage (int);
-\f
+
/** Globals and flags. */
static int mri_mode;
struct stat sbuf;
bfd *arch;
char **matching;
+ const char *arch_target = target;
+ const struct bfd_target *plugin_vec;
bfd_set_error (bfd_error_no_error);
- if (target == NULL)
- target = plugin_target;
-
if (stat (archive_filename, &sbuf) != 0)
{
#if !defined(__GO32__) || defined(__DJGPP__)
/* If the target isn't set, try to figure out the target to use
for the archive from the first object on the list. */
- if (target == NULL && file != NULL)
+ if (arch_target == NULL && file != NULL)
{
bfd *obj;
- obj = bfd_openr (file, target);
+ obj = bfd_openr (file, arch_target);
if (obj != NULL)
{
if (bfd_check_format (obj, bfd_object)
&& bfd_target_supports_archives (obj))
- target = bfd_get_target (obj);
+ arch_target = bfd_get_target (obj);
(void) bfd_close (obj);
}
}
output_filename = xstrdup (archive_filename);
/* Create an empty archive. */
- arch = bfd_openw (archive_filename, target);
+ arch = bfd_openw (archive_filename, arch_target);
if (arch == NULL
|| ! bfd_set_format (arch, bfd_archive)
|| ! bfd_close (arch))
non_fatal (_("creating %s"), archive_filename);
}
- arch = bfd_openr (archive_filename, target);
+ arch = bfd_openr (archive_filename, arch_target);
if (arch == NULL)
{
bloser:
}
}
+ /* We didn't open the archive using plugin_target, because the
+ plugin bfd_target does not support archives. Select
+ plugin_target now for elements so that we can recognise LTO IR
+ files and read IR symbols for use in the archive map. */
+ plugin_vec = NULL;
+ if (!target && plugin_target)
+ plugin_vec = bfd_find_target (plugin_target, NULL);
+
+ /* Open all the archive contents. */
last_one = &(arch->archive_next);
- /* Read all the contents right away, regardless. */
for (next_one = bfd_openr_next_archived_file (arch, NULL);
next_one;
next_one = bfd_openr_next_archived_file (arch, next_one))
{
+ set_plugin_target (next_one, plugin_vec);
*last_one = next_one;
last_one = &next_one->archive_next;
}
}
else
{
+ const char *targ = target ? target : plugin_target;
replaced = ar_emul_replace (after_bfd, *files_to_move,
- target, verbose);
+ targ, verbose);
}
if (replaced)
{
}
else
{
- changed |= ar_emul_append (after_bfd, *files_to_move, target,
+ const char *targ = target ? target : plugin_target;
+ changed |= ar_emul_append (after_bfd, *files_to_move, targ,
verbose, make_thin_archive);
}
#include "bucomm.h"
#include "arsup.h"
-static void map_over_list
- (bfd *, void (*function) (bfd *, bfd *), struct list *);
-static void ar_directory_doer (bfd *, bfd *);
-static void ar_addlib_doer (bfd *, bfd *);
-
extern int verbose;
extern int deterministic;
static int temp_fd;
static FILE *outfile;
+#if BFD_SUPPORTS_PLUGINS
+static const char *plugin_target = "plugin";
+#else
+static const char *plugin_target = NULL;
+#endif
+
static void
map_over_list (bfd *arch, void (*function) (bfd *, bfd *), struct list *list)
{
bfd *element;
bfd *ibfd;
-#if BFD_SUPPORTS_PLUGINS
- ibfd = bfd_openr (name, "plugin");
-#else
ibfd = bfd_openr (name, NULL);
-#endif
if (!ibfd)
{
ptr = &(obfd->archive_head);
element = bfd_openr_next_archived_file (ibfd, NULL);
+#if BFD_SUPPORTS_PLUGINS
+ const struct bfd_target *plugin_vec
+ = bfd_find_target (plugin_target, NULL);
+#endif
while (element)
{
+#if BFD_SUPPORTS_PLUGINS
+ set_plugin_target (element, plugin_vec);
+#endif
*ptr = element;
ptr = &element->archive_next;
element = bfd_openr_next_archived_file (ibfd, element);
{
bfd *abfd;
-#if BFD_SUPPORTS_PLUGINS
- abfd = bfd_openr (list->name, "plugin");
-#else
- abfd = bfd_openr (list->name, NULL);
-#endif
+ abfd = bfd_openr (list->name, plugin_target);
if (!abfd)
{
fprintf (stderr, _("%s: can't open file %s\n"),
if (FILENAME_CMP (bfd_get_filename (member), list->name) == 0)
{
/* Found the one to replace. */
- bfd *abfd = bfd_openr (list->name, NULL);
+ bfd *abfd = bfd_openr (list->name, plugin_target);
if (!abfd)
{
if (!found)
{
- bfd *abfd = bfd_openr (list->name, NULL);
+ bfd *abfd = bfd_openr (list->name, plugin_target);
fprintf (stderr,_("%s: can't find module file %s\n"),
program_name, list->name);
if (!found)
{
- bfd_openr (list->name, NULL);
fprintf (stderr, _("%s: can't find module file %s\n"),
program_name, list->name);
}
((*res) = (a), (*res) *= (b), (b) != 0 && (*res) / (b) != (a))
#endif
+/* Change ABFD target vector to TARG. ABFD is an archive element.
+ TARG is plugin_vec, or NULL if plugins are not supported. */
+static inline void
+set_plugin_target (bfd *abfd, const struct bfd_target *targ)
+{
+ /* Don't change the target for archives like pdb that handle
+ elements specially, as detected by my_archive being NULL. */
+ if (abfd->my_archive && targ)
+ {
+ abfd->xvec = targ;
+ /* Arrange for the plugin target to be tried first in
+ bfd_check_format. */
+ abfd->target_defaulted = false;
+ }
+}
+
#endif /* _BUCOMM_H */
if (print_armap)
print_symdef_entry (file);
+ /* We didn't open the archive using plugin_target, because the
+ plugin bfd_target does not support archives. Select
+ plugin_target now for elements so that we can recognise LTO IR
+ files and print IR symbols. */
+ const struct bfd_target *plugin_vec = NULL;
+ if (!target && plugin_target)
+ plugin_vec = bfd_find_target (plugin_target, NULL);
+
bfd *last_arfile = NULL;
for (;;)
{
if (last_arfile != NULL)
bfd_close (last_arfile);
+ set_plugin_target (arfile, plugin_vec);
+
char **matching;
if (bfd_check_format_matches (arfile, bfd_object, &matching))
{