#define BFD_TRADITIONAL_FORMAT 0x400
/* This flag indicates that the BFD contents are actually cached
- in memory. If this is set, iostream points to a bfd_in_memory
- struct. */
+ in memory. If this is set, iostream points to a malloc'd
+ bfd_in_memory struct. */
#define BFD_IN_MEMORY 0x800
/* This BFD has been created by the linker and doesn't correspond
.#define BFD_TRADITIONAL_FORMAT 0x400
.
. {* This flag indicates that the BFD contents are actually cached
-. in memory. If this is set, iostream points to a bfd_in_memory
-. struct. *}
+. in memory. If this is set, iostream points to a malloc'd
+. bfd_in_memory struct. *}
.#define BFD_IN_MEMORY 0x800
.
. {* This BFD has been created by the linker and doesn't correspond
won't do anything unless abfd->iovec is the cache_iovec. */
bfd_cache_close (abfd);
abfd->iovec = preserve->iovec;
- abfd->iostream = preserve->iostream;
+
+ if (abfd->iostream != preserve->iostream)
+ {
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ free (abfd->iostream);
+ abfd->iostream = preserve->iostream;
+ }
+
/* Handle in-memory to file backed transition. */
if ((abfd->flags & BFD_CLOSED_BY_CACHE) != 0
&& (abfd->flags & BFD_IN_MEMORY) != 0
else
free ((char *) bfd_get_filename (abfd));
+ if ((abfd->flags & BFD_IN_MEMORY) != 0)
+ free (abfd->iostream);
free (abfd->arelt_data);
free (abfd);
}
abfd->section_count = 0;
abfd->usrdata = NULL;
abfd->cacheable = false;
- abfd->flags |= BFD_IN_MEMORY;
abfd->mtime_set = false;
abfd->target_defaulted = true;