forked from Imagelibrary/binutils-gdb
close last arfile before processing current arfile
This also reduces peak memory a little. * dlltool.c (identify_search_archive): Close last_arfile earlier. Report an error if bfd_openr_next_archived_file returns the same bfd. Localise variables. * nm.c (display_archive): Likewise. * objdump.c (display_any_bfd): Likewise. * size.c (display_archive): Likewise.
This commit is contained in:
@@ -3322,21 +3322,25 @@ identify_search_archive (bfd * abfd,
|
|||||||
void (* operation) (bfd *, bfd *, void *),
|
void (* operation) (bfd *, bfd *, void *),
|
||||||
void * user_storage)
|
void * user_storage)
|
||||||
{
|
{
|
||||||
bfd * arfile = NULL;
|
|
||||||
bfd *last_arfile = NULL;
|
bfd *last_arfile = NULL;
|
||||||
char ** matching;
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
arfile = bfd_openr_next_archived_file (abfd, arfile);
|
bfd *arfile = bfd_openr_next_archived_file (abfd, last_arfile);
|
||||||
|
if (arfile == NULL
|
||||||
if (arfile == NULL)
|
|| arfile == last_arfile)
|
||||||
{
|
{
|
||||||
|
if (arfile != NULL)
|
||||||
|
bfd_set_error (bfd_error_malformed_archive);
|
||||||
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
||||||
bfd_fatal (bfd_get_filename (abfd));
|
bfd_fatal (bfd_get_filename (abfd));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (last_arfile != NULL)
|
||||||
|
bfd_close (last_arfile);
|
||||||
|
|
||||||
|
char **matching;
|
||||||
if (bfd_check_format_matches (arfile, bfd_object, &matching))
|
if (bfd_check_format_matches (arfile, bfd_object, &matching))
|
||||||
(*operation) (arfile, abfd, user_storage);
|
(*operation) (arfile, abfd, user_storage);
|
||||||
else
|
else
|
||||||
@@ -3345,25 +3349,12 @@ identify_search_archive (bfd * abfd,
|
|||||||
free (matching);
|
free (matching);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_arfile != NULL)
|
|
||||||
{
|
|
||||||
bfd_close (last_arfile);
|
|
||||||
/* PR 17512: file: 8b2168d4. */
|
|
||||||
if (last_arfile == arfile)
|
|
||||||
{
|
|
||||||
last_arfile = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
last_arfile = arfile;
|
last_arfile = arfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_arfile != NULL)
|
if (last_arfile != NULL)
|
||||||
{
|
|
||||||
bfd_close (last_arfile);
|
bfd_close (last_arfile);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Call the identify_search_section() function for each section of this
|
/* Call the identify_search_section() function for each section of this
|
||||||
archive member. */
|
archive member. */
|
||||||
|
|||||||
@@ -1566,26 +1566,29 @@ set_print_format (bfd *file)
|
|||||||
static void
|
static void
|
||||||
display_archive (bfd *file)
|
display_archive (bfd *file)
|
||||||
{
|
{
|
||||||
bfd *arfile = NULL;
|
|
||||||
bfd *last_arfile = NULL;
|
|
||||||
char **matching;
|
|
||||||
|
|
||||||
format->print_archive_filename (bfd_get_filename (file));
|
format->print_archive_filename (bfd_get_filename (file));
|
||||||
|
|
||||||
if (print_armap)
|
if (print_armap)
|
||||||
print_symdef_entry (file);
|
print_symdef_entry (file);
|
||||||
|
|
||||||
|
bfd *last_arfile = NULL;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
arfile = bfd_openr_next_archived_file (file, arfile);
|
bfd *arfile = bfd_openr_next_archived_file (file, last_arfile);
|
||||||
|
if (arfile == NULL
|
||||||
if (arfile == NULL)
|
|| arfile == last_arfile)
|
||||||
{
|
{
|
||||||
|
if (arfile != NULL)
|
||||||
|
bfd_set_error (bfd_error_malformed_archive);
|
||||||
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
||||||
bfd_nonfatal (bfd_get_filename (file));
|
bfd_nonfatal (bfd_get_filename (file));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (last_arfile != NULL)
|
||||||
|
bfd_close (last_arfile);
|
||||||
|
|
||||||
|
char **matching;
|
||||||
if (bfd_check_format_matches (arfile, bfd_object, &matching))
|
if (bfd_check_format_matches (arfile, bfd_object, &matching))
|
||||||
{
|
{
|
||||||
set_print_format (arfile);
|
set_print_format (arfile);
|
||||||
@@ -1600,12 +1603,6 @@ display_archive (bfd *file)
|
|||||||
list_matching_formats (matching);
|
list_matching_formats (matching);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (last_arfile != NULL)
|
|
||||||
{
|
|
||||||
bfd_close (last_arfile);
|
|
||||||
if (arfile == last_arfile)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
last_arfile = arfile;
|
last_arfile = arfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5888,9 +5888,6 @@ display_any_bfd (bfd *file, int level)
|
|||||||
/* If the file is an archive, process all of its elements. */
|
/* If the file is an archive, process all of its elements. */
|
||||||
if (bfd_check_format (file, bfd_archive))
|
if (bfd_check_format (file, bfd_archive))
|
||||||
{
|
{
|
||||||
bfd *arfile = NULL;
|
|
||||||
bfd *last_arfile = NULL;
|
|
||||||
|
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
printf (_("In archive %s:\n"), sanitize_string (bfd_get_filename (file)));
|
printf (_("In archive %s:\n"), sanitize_string (bfd_get_filename (file)));
|
||||||
else if (level > 100)
|
else if (level > 100)
|
||||||
@@ -5905,30 +5902,25 @@ display_any_bfd (bfd *file, int level)
|
|||||||
printf (_("In nested archive %s:\n"),
|
printf (_("In nested archive %s:\n"),
|
||||||
sanitize_string (bfd_get_filename (file)));
|
sanitize_string (bfd_get_filename (file)));
|
||||||
|
|
||||||
|
bfd *last_arfile = NULL;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
bfd_set_error (bfd_error_no_error);
|
bfd *arfile = bfd_openr_next_archived_file (file, last_arfile);
|
||||||
|
if (arfile == NULL
|
||||||
arfile = bfd_openr_next_archived_file (file, arfile);
|
|| arfile == last_arfile)
|
||||||
if (arfile == NULL)
|
|
||||||
{
|
{
|
||||||
|
if (arfile != NULL)
|
||||||
|
bfd_set_error (bfd_error_malformed_archive);
|
||||||
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
||||||
my_bfd_nonfatal (bfd_get_filename (file));
|
my_bfd_nonfatal (bfd_get_filename (file));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (last_arfile != NULL)
|
||||||
|
bfd_close (last_arfile);
|
||||||
|
|
||||||
display_any_bfd (arfile, level + 1);
|
display_any_bfd (arfile, level + 1);
|
||||||
|
|
||||||
if (last_arfile != NULL)
|
|
||||||
{
|
|
||||||
bfd_close (last_arfile);
|
|
||||||
/* PR 17512: file: ac585d01. */
|
|
||||||
if (arfile == last_arfile)
|
|
||||||
{
|
|
||||||
last_arfile = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
last_arfile = arfile;
|
last_arfile = arfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -368,16 +368,15 @@ display_bfd (bfd *abfd)
|
|||||||
static void
|
static void
|
||||||
display_archive (bfd *file)
|
display_archive (bfd *file)
|
||||||
{
|
{
|
||||||
bfd *arfile = (bfd *) NULL;
|
bfd *last_arfile = NULL;
|
||||||
bfd *last_arfile = (bfd *) NULL;
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
bfd_set_error (bfd_error_no_error);
|
bfd *arfile = bfd_openr_next_archived_file (file, last_arfile);
|
||||||
|
if (arfile == NULL
|
||||||
arfile = bfd_openr_next_archived_file (file, arfile);
|
|| arfile == last_arfile)
|
||||||
if (arfile == NULL)
|
|
||||||
{
|
{
|
||||||
|
if (arfile != NULL)
|
||||||
|
bfd_set_error (bfd_error_malformed_archive);
|
||||||
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
if (bfd_get_error () != bfd_error_no_more_archived_files)
|
||||||
{
|
{
|
||||||
bfd_nonfatal (bfd_get_filename (file));
|
bfd_nonfatal (bfd_get_filename (file));
|
||||||
@@ -386,17 +385,10 @@ display_archive (bfd *file)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
display_bfd (arfile);
|
|
||||||
|
|
||||||
if (last_arfile != NULL)
|
if (last_arfile != NULL)
|
||||||
{
|
|
||||||
bfd_close (last_arfile);
|
bfd_close (last_arfile);
|
||||||
|
|
||||||
/* PR 17512: file: a244edbc. */
|
display_bfd (arfile);
|
||||||
if (last_arfile == arfile)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
last_arfile = arfile;
|
last_arfile = arfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user