+2019-08-29 Alan Modra <amodra@gmail.com>
+
+ PR 24891
+ * bfd.c (struct bfd): Add no_element_cache.
+ * archive.c (_bfd_get_elt_at_filepos): Don't add element to
+ archive cache when no_element_cache.
+ (bfd_generic_archive_p): Set no_element_cache when opening first
+ element to check format. Close first element too.
+ (do_slurp_bsd_armap): Don't zero ardata->cache here.
+ * bfd-in2.h: Regenerate.
+
2019-08-24 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc64_elf_edit_toc): Exclude undefined weak
/* Copy is_linker_input. */
n_bfd->is_linker_input = archive->is_linker_input;
- if (_bfd_add_bfd_to_archive_cache (archive, filepos, n_bfd))
+ if (archive->no_element_cache
+ || _bfd_add_bfd_to_archive_cache (archive, filepos, n_bfd))
return n_bfd;
free (new_areldata);
if (abfd->target_defaulted && bfd_has_map (abfd))
{
bfd *first;
+ unsigned int save;
/* This archive has a map, so we may presume that the contents
are object files. Make sure that if the first file in the
normal archive, regardless of the format of the object files.
We do accept an empty archive. */
+ save = abfd->no_element_cache;
+ abfd->no_element_cache = 1;
first = bfd_openr_next_archived_file (abfd, NULL);
+ abfd->no_element_cache = save;
if (first != NULL)
{
first->target_defaulted = FALSE;
if (bfd_check_format (first, bfd_object)
&& first->xvec != abfd->xvec)
bfd_set_error (bfd_error_wrong_object_format);
- /* And we ought to close `first' here too. */
+ bfd_close (first);
}
}
goto byebye;
}
- ardata->cache = 0;
rbase = raw_armap + BSD_SYMDEF_COUNT_SIZE;
stringbase = ((char *) rbase
+ ardata->symdef_count * BSD_SYMDEF_SIZE
/* Set if this is a thin archive. */
unsigned int is_thin_archive : 1;
+ /* Set if this archive should not cache element positions. */
+ unsigned int no_element_cache : 1;
+
/* Set if only required symbols should be added in the link hash table for
this object. Used by VMS linkers. */
unsigned int selective_search : 1;
. {* Set if this is a thin archive. *}
. unsigned int is_thin_archive : 1;
.
+. {* Set if this archive should not cache element positions. *}
+. unsigned int no_element_cache : 1;
+.
. {* Set if only required symbols should be added in the link hash table for
. this object. Used by VMS linkers. *}
. unsigned int selective_search : 1;