Set my_archive for thin archives

LTO plugin support in plugin_maybe_claim wants to close the IR bfd
after replacing it with the recompiled object, but can't do so for
archive elements due to various pointers that access the archive bfd.
Thin archives have the same problem.  They too cannot have their
element bfds closed.

	PR ld/20241
bfd/
	* archive.c (open_nested_file): Set my_archive.
	* bfd.c (_bfd_default_error_handler <%B>): Exclude archive file name
	for thin archives.
	* bfdio.c (bfd_tell): Don't adjust origin for thin archives.
	(bfd_seek): Likewise.
	* bfdwin.c (bfd_get_file_window): Likewise.
	* cache.c (cache_bmmap): Likewise.
	(bfd_cache_lookup_worker): Don't look in my_archive for thin archives.
	* mach-o.c (bfd_mach_o_follow_dsym): Don't open my_archive for
	thin archives.
	* plugin.c (try_claim): Likewise.
	* xcofflink.c (xcoff_link_add_dynamic_symbols): Use import path of
	file within thin archive, not the archive.
binutils/
	* bucomm.c (bfd_get_archive_filename): Return file name within thin
	archive.
ld/
	* ldmain.c (add_archive_element): Just print file name of file within
	thin archives.
	* ldmisc.c (vfinfo): Likewise.
	* plugin.c (plugin_object_p): Open file within thin archives.
	(plugin_maybe_claim): Expand comment.
This commit is contained in:
Alan Modra
2016-06-14 13:12:00 +09:30
parent 57bc0e78e9
commit b0cffb4767
15 changed files with 66 additions and 19 deletions

View File

@ -1089,7 +1089,8 @@ plugin_object_p (bfd *ibfd)
return NULL;
}
inarchive = bfd_my_archive (ibfd) != NULL;
inarchive = (bfd_my_archive (ibfd) != NULL
&& !bfd_is_thin_archive (bfd_my_archive (ibfd)));
name = inarchive ? bfd_my_archive (ibfd)->filename : ibfd->filename;
fd = open (name, O_RDONLY | O_BINARY);
@ -1201,8 +1202,10 @@ plugin_maybe_claim (lang_input_statement_type *entry)
/* Discard the real file's BFD and substitute the dummy one. */
/* BFD archive handling caches elements so we can't call
bfd_close for archives. */
/* We can't call bfd_close on archives. BFD archive handling
caches elements, and add_archive_element keeps pointers to
the_bfd and the_bfd->filename in a lang_input_statement_type
linker script statement. */
if (entry->the_bfd->my_archive == NULL)
bfd_close (entry->the_bfd);
entry->the_bfd = abfd;