PR binutils/15474
authorAlan Modra <amodra@gmail.com>
Wed, 22 May 2013 06:13:59 +0000 (06:13 +0000)
committerAlan Modra <amodra@gmail.com>
Wed, 22 May 2013 06:13:59 +0000 (06:13 +0000)
* srec.c (srec_set_section_contents): Properly convert size
and offset to address when octets_per_byte is not unity.

bfd/ChangeLog
bfd/srec.c

index 49f3487d16bd70c6414341f666e30093adce7464..5055dc46c2420153df06f774d716e6f64f65eed5 100644 (file)
@@ -1,3 +1,9 @@
+2013-05-22  Ralf Dreesen  <gamma@dreesen.net>
+
+       PR binutils/15474
+       * srec.c (srec_set_section_contents): Properly convert size
+       and offset to address when octets_per_byte is not unity.
+
 2013-05-20  Maciej W. Rozycki  <macro@linux-mips.org>
 
        * elf32-vax.c (elf_vax_instantiate_got_entries): Only set the
index 6226773387252b3d4e9f5df43e832e5a937e9161..ded9e76ca28992e7d5bfd0ea6aa60c9136e7e09f 100644 (file)
@@ -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
This page took 0.04046 seconds and 4 git commands to generate.