* [PATCH 4/5] fix archive cache for thin archives
@ 2012-08-03 14:56 Tom Tromey
2012-08-03 18:00 ` Alan Modra
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2012-08-03 14:56 UTC (permalink / raw)
To: Binutils Development
The previous archive cache fix did not account for thin archives.
Currently, when a member of a thin archive is opened, there is no
back-link to the parent archive. This patch adds such a link, so that
the BFD archive code can clean up the thin archive cache when a member
is closed.
I took this approach rather than overload my_archive, because it
seemed simpler than fixing all the users of my_archive to have a
special case for thin archives. However, if that is preferred, I can
attempt it.
In the case of flattened thin archives -- where a thin archive refers
to an ordinary archive -- the intermediate archive BFD is not
available to the BFD user. So, no change needs to be done there, it
is already handled properly.
* archive.c (_bfd_delete_archive_data): Handle thin archives.
(_bfd_get_elt_at_filepos): Set 'thin_archive' field.
* bfd-in2.h: Rebuild.
* bfd.c (bfd) <thin_archive>: New field.
---
bfd/archive.c | 8 +++++++-
bfd/bfd-in2.h | 1 +
bfd/bfd.c | 3 ++-
3 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/bfd/archive.c b/bfd/archive.c
index f84a8fc..8407745 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -317,13 +317,18 @@ void
_bfd_delete_archive_data (bfd *abfd)
{
struct artdata *ardata = bfd_ardata (abfd);
+ bfd *archive = NULL;
if (ardata && ardata->cache)
htab_delete (ardata->cache);
if (abfd->my_archive)
+ archive = abfd->my_archive;
+ else if (abfd->thin_archive)
+ archive = abfd->thin_archive;
+ if (archive)
{
- ardata = bfd_ardata (abfd->my_archive);
+ ardata = bfd_ardata (archive);
if (ardata && ardata->cache)
{
/* We have to traverse the hash table because there is no
@@ -705,6 +710,7 @@ _bfd_get_elt_at_filepos (bfd *archive, file_ptr filepos)
n_nfd = bfd_openr (filename, target);
if (n_nfd == NULL)
bfd_set_error (bfd_error_malformed_archive);
+ n_nfd->thin_archive = archive;
}
else
{
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index c7ce4cc..dcfdfdf 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -5618,6 +5618,7 @@ struct bfd
struct bfd *archive_head; /* The first BFD in the archive. */
struct bfd *nested_archives; /* List of nested archive in a flattened
thin archive. */
+ struct bfd *thin_archive; /* The containing thin archive. */
/* A chain of BFD structures involved in a link. */
struct bfd *link_next;
diff --git a/bfd/bfd.c b/bfd/bfd.c
index eed1896..480f2f6 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1,6 +1,6 @@
/* Generic BFD library interface and support routines.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Free Software Foundation, Inc.
Written by Cygnus Support.
@@ -217,6 +217,7 @@ CODE_FRAGMENT
. struct bfd *archive_head; {* The first BFD in the archive. *}
. struct bfd *nested_archives; {* List of nested archive in a flattened
. thin archive. *}
+. struct bfd *thin_archive; {* The containing thin archive. *}
.
. {* A chain of BFD structures involved in a link. *}
. struct bfd *link_next;
--
1.7.7.6
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 4/5] fix archive cache for thin archives
2012-08-03 14:56 [PATCH 4/5] fix archive cache for thin archives Tom Tromey
@ 2012-08-03 18:00 ` Alan Modra
0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2012-08-03 18:00 UTC (permalink / raw)
To: Tom Tromey; +Cc: Binutils Development
On Fri, Aug 03, 2012 at 08:55:17AM -0600, Tom Tromey wrote:
> I took this approach rather than overload my_archive, because it
> seemed simpler than fixing all the users of my_archive to have a
> special case for thin archives. However, if that is preferred, I can
> attempt it.
I'd prefer to see the extra field added to struct areltdata rather
than to struct bfd.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-03 16:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-03 14:56 [PATCH 4/5] fix archive cache for thin archives Tom Tromey
2012-08-03 18:00 ` Alan Modra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).