Add an option to the archiver to add a section recording library dependencies.

* ar.c (long_options): Add --record-libdeps.
	(usage): Mention the new option.
	(decode_options): Handle the new option.
	(replace_members): If necessary, create a bfd to hold the libdeps
	description.
	* binemul.c (ar_emul_append_bfd): New function.
	(ar_emul_replace_bfd): New function.
	(ar_emul_default_append): Replace file_name and target arguments
	with new_bfd argument.
	(ar_emul_default_replace): Likewise.
	* binemul.h: Update prototypes.
	(struct bin_emulation_xfer_struct): Update fields.
	* doc/binutils.texi: Document the new option.
	* NEWS: Mention the new feature.
	* emul_aix.c (ar_emul_aix_append): Update.
	(ar_emul_aix_replace): Likewise.
	* testsuite/binutils-all/ar.exp: Add test of new feature.
This commit is contained in:
Howard Chu
2020-11-03 15:12:47 +00:00
committed by Nick Clifton
parent fd65497db4
commit f3016d6ce1
8 changed files with 214 additions and 49 deletions

View File

@@ -42,8 +42,23 @@ bfd_boolean
ar_emul_append (bfd **after_bfd, char *file_name, const char *target,
bfd_boolean verbose, bfd_boolean flatten)
{
bfd *new_bfd;
new_bfd = bfd_openr (file_name, target);
AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
if (bin_dummy_emulation.ar_append)
return bin_dummy_emulation.ar_append (after_bfd, file_name, target,
return bin_dummy_emulation.ar_append (after_bfd, new_bfd,
verbose, flatten);
return FALSE;
}
bfd_boolean
ar_emul_append_bfd (bfd **after_bfd, bfd *new_bfd,
bfd_boolean verbose, bfd_boolean flatten)
{
if (bin_dummy_emulation.ar_append)
return bin_dummy_emulation.ar_append (after_bfd, new_bfd,
verbose, flatten);
return FALSE;
@@ -93,38 +108,44 @@ do_ar_emul_append (bfd **after_bfd, bfd *new_bfd,
}
bfd_boolean
ar_emul_default_append (bfd **after_bfd, char *file_name,
const char *target, bfd_boolean verbose,
bfd_boolean flatten)
ar_emul_default_append (bfd **after_bfd, bfd *new_bfd,
bfd_boolean verbose, bfd_boolean flatten)
{
bfd *new_bfd;
new_bfd = bfd_openr (file_name, target);
AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
return do_ar_emul_append (after_bfd, new_bfd, verbose, flatten, any_ok);
}
bfd_boolean
ar_emul_replace (bfd **after_bfd, char *file_name, const char *target,
bfd_boolean verbose)
{
if (bin_dummy_emulation.ar_replace)
return bin_dummy_emulation.ar_replace (after_bfd, file_name,
target, verbose);
return FALSE;
}
bfd_boolean
ar_emul_default_replace (bfd **after_bfd, char *file_name,
const char *target, bfd_boolean verbose)
{
bfd *new_bfd;
new_bfd = bfd_openr (file_name, target);
AR_EMUL_ELEMENT_CHECK (new_bfd, file_name);
AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, file_name);
if (bin_dummy_emulation.ar_replace)
return bin_dummy_emulation.ar_replace (after_bfd, new_bfd,
verbose);
return FALSE;
}
bfd_boolean
ar_emul_replace_bfd (bfd **after_bfd, bfd *new_bfd,
bfd_boolean verbose)
{
if (bin_dummy_emulation.ar_replace)
return bin_dummy_emulation.ar_replace (after_bfd, new_bfd,
verbose);
return FALSE;
}
bfd_boolean
ar_emul_default_replace (bfd **after_bfd, bfd *new_bfd,
bfd_boolean verbose)
{
AR_EMUL_REPLACE_PRINT_VERBOSE (verbose, bfd_get_filename (new_bfd));
new_bfd->archive_next = *after_bfd;
*after_bfd = new_bfd;