Don't choose plugin target in binutils/

Instead make bfd_check_format try the plugin target first when the
user hasn't supplied a target.

bfd/
	* format.c (bfd_check_format_matches): Try for a plugin target
	match first.
	* targets.c (bfd_find_target): Don't specially treat "plugin".
binutils/
	* ar.c (plugin_target): Delete.
	(open_inarch): Don't set target of archive elements.
	(replace_members): Use target rather than plugin_target when
	opening replacement or additional files.
	* arsup.c (plugin_target): Delete.  Replace all uses with NULL.
	(ar_open): Don't set element target.
	* bucomm.h (set_plugin_target): Delete.
	* nm.c (plugin_target): Delete.
	(display_archive): Don't set element target.
	(display_file): Alway use target when opening file.
	* objcopy.c (copy_archive): Don't use plugin target for output
	elements.
	* NEWS: Mention stricter target checking.
This commit is contained in:
Alan Modra
2025-08-18 18:33:54 +09:30
parent c3eb17bae4
commit 5e83077d55
8 changed files with 48 additions and 90 deletions

View File

@@ -41,12 +41,6 @@ static char *temp_name;
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)
{
@@ -203,15 +197,8 @@ ar_open (char *name, int t)
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);
@@ -270,7 +257,7 @@ ar_addmod (struct list *list)
{
bfd *abfd;
abfd = bfd_openr (list->name, plugin_target);
abfd = bfd_openr (list->name, NULL);
if (!abfd)
{
fprintf (stderr, _("%s: can't open file %s\n"),
@@ -397,7 +384,7 @@ ar_replace (struct list *list)
if (FILENAME_CMP (bfd_get_filename (member), list->name) == 0)
{
/* Found the one to replace. */
bfd *abfd = bfd_openr (list->name, plugin_target);
bfd *abfd = bfd_openr (list->name, NULL);
if (!abfd)
{
@@ -421,7 +408,7 @@ ar_replace (struct list *list)
if (!found)
{
bfd *abfd = bfd_openr (list->name, plugin_target);
bfd *abfd = bfd_openr (list->name, NULL);
fprintf (stderr,_("%s: can't find module file %s\n"),
program_name, list->name);