+2018-07-02 Jeff Muizelaar <jrmuizel@gmail.com>
+ Tom Tromey <tom@tromey.com>
+
+ PR 13157
+ PR 21787
+ * mach-o.c (bfd_mach_o_fat_close_and_cleanup): New function.
+ (bfd_mach_o_close_and_cleanup): Redefine.
+ * archive.c (_bfd_unlink_from_archive_parent): New function,
+ extracted from..
+ (_bfd_archive_close_and_cleanup): ..here.
+ (bfd_generic_archive_p): Do not clear archive's format.
+ * libbfd-in.h (_bfd_unlink_from_archive_parent): Declare.
+ * libbfd.h: Regenerate.
+
2018-07-02 Thomas Preud'homme <thomas.preudhomme@arm.com>
* archures.c (bfd_mach_arm_5TEJ, bfd_mach_arm_6, bfd_mach_arm_6KZ,
&& ! bfd_is_thin_archive (abfd))
{
bfd_set_error (bfd_error_wrong_format);
- if (abfd->format == bfd_archive)
- abfd->format = bfd_unknown;
return NULL;
}
return 1;
}
+void
+_bfd_unlink_from_archive_parent (bfd *abfd)
+{
+ if (arch_eltdata (abfd) != NULL)
+ {
+ struct areltdata *ared = arch_eltdata (abfd);
+ htab_t htab = (htab_t) ared->parent_cache;
+
+ if (htab)
+ {
+ struct ar_cache ent;
+ void **slot;
+
+ ent.ptr = ared->key;
+ slot = htab_find_slot (htab, &ent, NO_INSERT);
+ if (slot != NULL)
+ {
+ BFD_ASSERT (((struct ar_cache *) *slot)->arbfd == abfd);
+ htab_clear_slot (htab, slot);
+ }
+ }
+ }
+}
+
bfd_boolean
_bfd_archive_close_and_cleanup (bfd *abfd)
{
bfd_ardata (abfd)->cache = NULL;
}
}
- if (arch_eltdata (abfd) != NULL)
- {
- struct areltdata *ared = arch_eltdata (abfd);
- htab_t htab = (htab_t) ared->parent_cache;
- if (htab)
- {
- struct ar_cache ent;
- void **slot;
+ _bfd_unlink_from_archive_parent (abfd);
- ent.ptr = ared->key;
- slot = htab_find_slot (htab, &ent, NO_INSERT);
- if (slot != NULL)
- {
- BFD_ASSERT (((struct ar_cache *) *slot)->arbfd == abfd);
- htab_clear_slot (htab, slot);
- }
- }
- }
if (abfd->is_linker_output)
(*abfd->link.hash->hash_table_free) (abfd);
#define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
extern bfd_boolean _bfd_archive_close_and_cleanup
(bfd *) ATTRIBUTE_HIDDEN;
+extern void _bfd_unlink_from_archive_parent (bfd *) ATTRIBUTE_HIDDEN;
#define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true
extern bfd_boolean _bfd_generic_new_section_hook
(bfd *, asection *) ATTRIBUTE_HIDDEN;
#define _bfd_generic_close_and_cleanup _bfd_archive_close_and_cleanup
extern bfd_boolean _bfd_archive_close_and_cleanup
(bfd *) ATTRIBUTE_HIDDEN;
+extern void _bfd_unlink_from_archive_parent (bfd *) ATTRIBUTE_HIDDEN;
#define _bfd_generic_bfd_free_cached_info _bfd_bool_bfd_true
extern bfd_boolean _bfd_generic_new_section_hook
(bfd *, asection *) ATTRIBUTE_HIDDEN;
return NULL;
}
+static bfd_boolean
+bfd_mach_o_fat_close_and_cleanup (bfd *abfd)
+{
+ _bfd_unlink_from_archive_parent (abfd);
+ return TRUE;
+}
+
int
bfd_mach_o_lookup_command (bfd *abfd,
bfd_mach_o_load_command_type type,
/* Not yet handled: creating an archive. */
#define bfd_mach_o_mkarchive _bfd_noarchive_mkarchive
-#define bfd_mach_o_close_and_cleanup _bfd_bool_bfd_true
+#define bfd_mach_o_close_and_cleanup bfd_mach_o_fat_close_and_cleanup
/* Not used. */
#define bfd_mach_o_generic_stat_arch_elt bfd_mach_o_fat_stat_arch_elt