summaryrefslogtreecommitdiff
path: root/bfd/ihex.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/ihex.c')
-rw-r--r--bfd/ihex.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/bfd/ihex.c b/bfd/ihex.c
index cee736ace7d..8188c01c89e 100644
--- a/bfd/ihex.c
+++ b/bfd/ihex.c
@@ -193,19 +193,16 @@ static boolean
ihex_mkobject (abfd)
bfd *abfd;
{
- if (abfd->tdata.ihex_data == NULL)
- {
- struct ihex_data_struct *tdata;
- bfd_size_type amt = sizeof (struct ihex_data_struct);
+ struct ihex_data_struct *tdata;
+ bfd_size_type amt = sizeof (struct ihex_data_struct);
- tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt);
- if (tdata == NULL)
- return false;
- abfd->tdata.ihex_data = tdata;
- tdata->head = NULL;
- tdata->tail = NULL;
- }
+ tdata = (struct ihex_data_struct *) bfd_alloc (abfd, amt);
+ if (tdata == NULL)
+ return false;
+ abfd->tdata.ihex_data = tdata;
+ tdata->head = NULL;
+ tdata->tail = NULL;
return true;
}
@@ -513,6 +510,7 @@ static const bfd_target *
ihex_object_p (abfd)
bfd *abfd;
{
+ PTR tdata_save;
bfd_byte b[9];
unsigned int i;
unsigned int type;
@@ -551,9 +549,14 @@ ihex_object_p (abfd)
}
/* OK, it looks like it really is an Intel Hex file. */
- if (! ihex_mkobject (abfd)
- || ! ihex_scan (abfd))
- return NULL;
+ tdata_save = abfd->tdata.any;
+ if (! ihex_mkobject (abfd) || ! ihex_scan (abfd))
+ {
+ if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
+ bfd_release (abfd, abfd->tdata.any);
+ abfd->tdata.any = tdata_save;
+ return NULL;
+ }
return abfd->xvec;
}
@@ -977,6 +980,7 @@ ihex_sizeof_headers (abfd, exec)
#define ihex_bfd_relax_section bfd_generic_relax_section
#define ihex_bfd_gc_sections bfd_generic_gc_sections
#define ihex_bfd_merge_sections bfd_generic_merge_sections
+#define ihex_bfd_discard_group bfd_generic_discard_group
#define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
#define ihex_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols