]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
archives and plugin target
authorAlan Modra <amodra@gmail.com>
Tue, 12 Aug 2025 13:16:36 +0000 (22:46 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 15 Aug 2025 22:07:08 +0000 (07:37 +0930)
commit46cd7e0dc8439b3f3bab1be553a9bea9a1bb5fe9
tree4a61acdcedc4e2a93d9c48a615a258ef70610e37
parentb71d1202f007157767c55d1a253632138efb4451
archives and plugin target

Automatically choosing "plugin" for the archive target when plugins
are enabled can result in making archives as specified by the plugin
target vec, ie. COFF style archives (also used by most ELF
binutils targets).  This is wrong for aix, hpux, vms, aout, macho
and possibly other targets, if compatibility with target system
archives matters.

This patch removes archive support entirely from the plugin target.
That means an archive will never get past bfd_check_format with a
target of plugin_vec, even if it is opened using "plugin".  Instead,
archives will have their elements opened using the plugin target
selected is such a way that the plugin target will be tried first in
bfd_check_format and then continue to try other targets if that fails.

The patch tries to avoid opening archives using "plugin" because that
is guaranteed to fail the first target check in bfd_check_format, but
mm.c still does so, and nested archives will also be opened using
"plugin".

The patch also fixes poor arsup.c plugin support.

bfd/
* plugin.c (plugin_vec): Remove archive support.
* configure.ac: Remove plugin archive warning, and don't disable
plugins by default on anything but aout targets.
* configure: Regenerate.
binutils/
* bucomm.h (set_plugin_target): New inline function.
* ar.c: Remove unneeded forward declarations.
(open_inarch): Don't use "plugin" if defaulting target when
opening an archive, use "plugin" when opening elements.
(replace_members): Use "plugin" when opening replacement or
additional elements.
* arsup.c: Remove unneeded forward declarations.
(plugin_target): New.
(ar_open): Don't open archives using "plugin", use it when
opening elements.
(ar_addmod): Use plugin_target.
(ar_replace): Use plugin_target when opening replacement or
additional elements.
(ar_extract): Don't bfd_openr.
* nm.c (display_archive): Open archive elements using the
"plugin" target.
bfd/configure
bfd/configure.ac
bfd/plugin.c
binutils/ar.c
binutils/arsup.c
binutils/bucomm.h
binutils/nm.c