* srec.c (tdata_type): Add field tail.
(srec_mkobject): Initialize tail. (srec_set_section_contents): Sort S record list by address.
This commit is contained in:
parent
67932b7d02
commit
d4d166835f
2 changed files with 38 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue Oct 18 12:56:43 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
|
||||||
|
|
||||||
|
* srec.c (tdata_type): Add field tail.
|
||||||
|
(srec_mkobject): Initialize tail.
|
||||||
|
(srec_set_section_contents): Sort S record list by address.
|
||||||
|
|
||||||
Mon Oct 17 11:38:16 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
|
Mon Oct 17 11:38:16 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
|
||||||
|
|
||||||
* elfcode.h (elf_map_symbols): Sort the symbols into a new array,
|
* elfcode.h (elf_map_symbols): Sort the symbols into a new array,
|
||||||
|
|
40
bfd/srec.c
40
bfd/srec.c
|
@ -182,6 +182,7 @@ typedef struct srec_data_list_struct srec_data_list_type;
|
||||||
typedef struct srec_data_struct
|
typedef struct srec_data_struct
|
||||||
{
|
{
|
||||||
srec_data_list_type *head;
|
srec_data_list_type *head;
|
||||||
|
srec_data_list_type *tail;
|
||||||
unsigned int type;
|
unsigned int type;
|
||||||
|
|
||||||
int done_symbol_read;
|
int done_symbol_read;
|
||||||
|
@ -247,7 +248,7 @@ fillup_symbols (abfd, buf, len, val)
|
||||||
p->value = val;
|
p->value = val;
|
||||||
p->flags = BSF_EXPORT | BSF_GLOBAL;
|
p->flags = BSF_EXPORT | BSF_GLOBAL;
|
||||||
p->section = bfd_abs_section_ptr;
|
p->section = bfd_abs_section_ptr;
|
||||||
p->udata = 0;
|
p->udata.p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
|
@ -327,7 +328,8 @@ srec_mkobject (abfd)
|
||||||
}
|
}
|
||||||
abfd->tdata.srec_data = tdata;
|
abfd->tdata.srec_data = tdata;
|
||||||
tdata->type = 1;
|
tdata->type = 1;
|
||||||
tdata->head = (srec_data_list_type *) NULL;
|
tdata->head = NULL;
|
||||||
|
tdata->tail = NULL;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -599,10 +601,11 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
|
||||||
bfd_size_type bytes_to_do;
|
bfd_size_type bytes_to_do;
|
||||||
{
|
{
|
||||||
tdata_type *tdata = abfd->tdata.srec_data;
|
tdata_type *tdata = abfd->tdata.srec_data;
|
||||||
srec_data_list_type *entry = (srec_data_list_type *)
|
register srec_data_list_type *entry;
|
||||||
bfd_alloc (abfd, sizeof (srec_data_list_type));
|
|
||||||
|
|
||||||
if (!entry)
|
entry = ((srec_data_list_type *)
|
||||||
|
bfd_alloc (abfd, sizeof (srec_data_list_type)));
|
||||||
|
if (entry == NULL)
|
||||||
{
|
{
|
||||||
bfd_set_error (bfd_error_no_memory);
|
bfd_set_error (bfd_error_no_memory);
|
||||||
return false;
|
return false;
|
||||||
|
@ -612,7 +615,7 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
|
||||||
&& (section->flags & SEC_LOAD))
|
&& (section->flags & SEC_LOAD))
|
||||||
{
|
{
|
||||||
unsigned char *data = (unsigned char *) bfd_alloc (abfd, bytes_to_do);
|
unsigned char *data = (unsigned char *) bfd_alloc (abfd, bytes_to_do);
|
||||||
if (!data)
|
if (data == NULL)
|
||||||
{
|
{
|
||||||
bfd_set_error (bfd_error_no_memory);
|
bfd_set_error (bfd_error_no_memory);
|
||||||
return false;
|
return false;
|
||||||
|
@ -636,8 +639,29 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
|
||||||
entry->data = data;
|
entry->data = data;
|
||||||
entry->where = section->lma + offset;
|
entry->where = section->lma + offset;
|
||||||
entry->size = bytes_to_do;
|
entry->size = bytes_to_do;
|
||||||
entry->next = tdata->head;
|
|
||||||
tdata->head = entry;
|
/* Sort the records by address. Optimize for the common case of
|
||||||
|
adding a record to the end of the list. */
|
||||||
|
if (tdata->tail != NULL
|
||||||
|
&& entry->where >= tdata->tail->where)
|
||||||
|
{
|
||||||
|
tdata->tail->next = entry;
|
||||||
|
entry->next = NULL;
|
||||||
|
tdata->tail = entry;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
register srec_data_list_type **look;
|
||||||
|
|
||||||
|
for (look = &tdata->head;
|
||||||
|
*look != NULL && (*look)->where < entry->where;
|
||||||
|
look = &(*look)->next)
|
||||||
|
;
|
||||||
|
entry->next = *look;
|
||||||
|
*look = entry;
|
||||||
|
if (entry->next == NULL)
|
||||||
|
tdata->tail = entry;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue