summaryrefslogtreecommitdiff
path: root/bfd/srec.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2013-05-22 06:13:59 +0000
committerAlan Modra <amodra@bigpond.net.au>2013-05-22 06:13:59 +0000
commit74f8ec63d087a477afa2f9cec6a91a60c06ff31e (patch)
treea38c99175a42400bb9c76016272d284f62dac1a9 /bfd/srec.c
parente154a632bc3d19b692fc0b5e13566096220195e3 (diff)
downloadbinutils-redhat-74f8ec63d087a477afa2f9cec6a91a60c06ff31e.tar.gz
PR binutils/15474
* srec.c (srec_set_section_contents): Properly convert size and offset to address when octets_per_byte is not unity.
Diffstat (limited to 'bfd/srec.c')
-rw-r--r--bfd/srec.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bfd/srec.c b/bfd/srec.c
index 6226773387..ded9e76ca2 100644
--- a/bfd/srec.c
+++ b/bfd/srec.c
@@ -870,6 +870,7 @@ srec_set_section_contents (bfd *abfd,
file_ptr offset,
bfd_size_type bytes_to_do)
{
+ int opb = bfd_octets_per_byte (abfd);
tdata_type *tdata = abfd->tdata.srec_data;
srec_data_list_type *entry;
@@ -892,16 +893,16 @@ srec_set_section_contents (bfd *abfd,
regardless of the siez of the addresses. */
if (S3Forced)
tdata->type = 3;
- else if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
+ else if ((section->lma + (offset + bytes_to_do) / opb - 1) <= 0xffff)
; /* The default, S1, is OK. */
- else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
+ else if ((section->lma + (offset + bytes_to_do) / opb - 1) <= 0xffffff
&& tdata->type <= 2)
tdata->type = 2;
else
tdata->type = 3;
entry->data = data;
- entry->where = section->lma + offset;
+ entry->where = section->lma + offset / opb;
entry->size = bytes_to_do;
/* Sort the records by address. Optimize for the common case of