Line 1... |
Line 1... |
/* BFD back-end for Intel Hex objects.
|
/* BFD back-end for Intel Hex objects.
|
Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
Copyright 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
|
2006, 2007 Free Software Foundation, Inc.
|
2006, 2007, 2009 Free Software Foundation, Inc.
|
Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
|
Written by Ian Lance Taylor of Cygnus Support <ian@cygnus.com>.
|
|
|
This file is part of BFD, the Binary File Descriptor library.
|
This file is part of BFD, the Binary File Descriptor library.
|
|
|
This program is free software; you can redistribute it and/or modify
|
This program is free software; you can redistribute it and/or modify
|
Line 175... |
Line 175... |
static bfd_boolean
|
static bfd_boolean
|
ihex_mkobject (bfd *abfd)
|
ihex_mkobject (bfd *abfd)
|
{
|
{
|
struct ihex_data_struct *tdata;
|
struct ihex_data_struct *tdata;
|
|
|
tdata = bfd_alloc (abfd, sizeof (* tdata));
|
tdata = (struct ihex_data_struct *) bfd_alloc (abfd, sizeof (* tdata));
|
if (tdata == NULL)
|
if (tdata == NULL)
|
return FALSE;
|
return FALSE;
|
|
|
abfd->tdata.ihex_data = tdata;
|
abfd->tdata.ihex_data = tdata;
|
tdata->head = NULL;
|
tdata->head = NULL;
|
Line 307... |
Line 307... |
|
|
/* Read the data bytes. */
|
/* Read the data bytes. */
|
chars = len * 2 + 2;
|
chars = len * 2 + 2;
|
if (chars >= bufsize)
|
if (chars >= bufsize)
|
{
|
{
|
buf = bfd_realloc (buf, (bfd_size_type) chars);
|
buf = (bfd_byte *) bfd_realloc (buf, (bfd_size_type) chars);
|
if (buf == NULL)
|
if (buf == NULL)
|
goto error_return;
|
goto error_return;
|
bufsize = chars;
|
bufsize = chars;
|
}
|
}
|
|
|
Line 359... |
Line 359... |
bfd_size_type amt;
|
bfd_size_type amt;
|
flagword flags;
|
flagword flags;
|
|
|
sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
|
sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
|
amt = strlen (secbuf) + 1;
|
amt = strlen (secbuf) + 1;
|
secname = bfd_alloc (abfd, amt);
|
secname = (char *) bfd_alloc (abfd, amt);
|
if (secname == NULL)
|
if (secname == NULL)
|
goto error_return;
|
goto error_return;
|
strcpy (secname, secbuf);
|
strcpy (secname, secbuf);
|
flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
|
flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
|
sec = bfd_make_section_with_flags (abfd, secname, flags);
|
sec = bfd_make_section_with_flags (abfd, secname, flags);
|
Line 581... |
Line 581... |
goto error_return;
|
goto error_return;
|
}
|
}
|
|
|
if (len * 2 > bufsize)
|
if (len * 2 > bufsize)
|
{
|
{
|
buf = bfd_realloc (buf, (bfd_size_type) len * 2);
|
buf = (bfd_byte *) bfd_realloc (buf, (bfd_size_type) len * 2);
|
if (buf == NULL)
|
if (buf == NULL)
|
goto error_return;
|
goto error_return;
|
bufsize = len * 2;
|
bufsize = len * 2;
|
}
|
}
|
|
|
Line 638... |
Line 638... |
if (section->used_by_bfd == NULL)
|
if (section->used_by_bfd == NULL)
|
{
|
{
|
section->used_by_bfd = bfd_alloc (abfd, section->size);
|
section->used_by_bfd = bfd_alloc (abfd, section->size);
|
if (section->used_by_bfd == NULL)
|
if (section->used_by_bfd == NULL)
|
return FALSE;
|
return FALSE;
|
if (! ihex_read_section (abfd, section, section->used_by_bfd))
|
if (! ihex_read_section (abfd, section,
|
|
(bfd_byte *) section->used_by_bfd))
|
return FALSE;
|
return FALSE;
|
}
|
}
|
|
|
memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
|
memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
|
(size_t) count);
|
(size_t) count);
|
Line 666... |
Line 667... |
if (count == 0
|
if (count == 0
|
|| (section->flags & SEC_ALLOC) == 0
|
|| (section->flags & SEC_ALLOC) == 0
|
|| (section->flags & SEC_LOAD) == 0)
|
|| (section->flags & SEC_LOAD) == 0)
|
return TRUE;
|
return TRUE;
|
|
|
n = bfd_alloc (abfd, sizeof (* n));
|
n = (struct ihex_data_list *) bfd_alloc (abfd, sizeof (* n));
|
if (n == NULL)
|
if (n == NULL)
|
return FALSE;
|
return FALSE;
|
|
|
data = bfd_alloc (abfd, count);
|
data = (bfd_byte *) bfd_alloc (abfd, count);
|
if (data == NULL)
|
if (data == NULL)
|
return FALSE;
|
return FALSE;
|
memcpy (data, location, (size_t) count);
|
memcpy (data, location, (size_t) count);
|
|
|
n->data = data;
|
n->data = data;
|
Line 931... |
Line 932... |
#define ihex_bfd_gc_sections bfd_generic_gc_sections
|
#define ihex_bfd_gc_sections bfd_generic_gc_sections
|
#define ihex_bfd_merge_sections bfd_generic_merge_sections
|
#define ihex_bfd_merge_sections bfd_generic_merge_sections
|
#define ihex_bfd_is_group_section bfd_generic_is_group_section
|
#define ihex_bfd_is_group_section bfd_generic_is_group_section
|
#define ihex_bfd_discard_group bfd_generic_discard_group
|
#define ihex_bfd_discard_group bfd_generic_discard_group
|
#define ihex_section_already_linked _bfd_generic_section_already_linked
|
#define ihex_section_already_linked _bfd_generic_section_already_linked
|
|
#define ihex_bfd_define_common_symbol bfd_generic_define_common_symbol
|
#define ihex_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
|
#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_hash_table_free _bfd_generic_link_hash_table_free
|
#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
#define ihex_bfd_link_add_symbols _bfd_generic_link_add_symbols
|
#define ihex_bfd_link_just_syms _bfd_generic_link_just_syms
|
#define ihex_bfd_link_just_syms _bfd_generic_link_just_syms
|
#define ihex_bfd_final_link _bfd_generic_final_link
|
#define ihex_bfd_final_link _bfd_generic_final_link
|