Add parens like the comment says.
[deliverable/binutils-gdb.git] / bfd / srec.c
index 36984c49bc7ec5e03d07d8d6e6f98b06ed8d672b..56022392421542a6b7a5b8116bac2bb4f3789e1b 100644 (file)
@@ -24,7 +24,7 @@ SUBSECTION
        S-Record handling
 
 DESCRIPTION
-       
+
        Ordinary S-Records cannot hold anything but addresses and
        data, so that's all that we implement.
 
@@ -42,10 +42,10 @@ DESCRIPTION
        up and output them when it's time to close the bfd.
 
        An s record looks like:
-       
+
 EXAMPLE
        S<type><length><address><data><checksum>
-       
+
 DESCRIPTION
        Where
        o length
@@ -61,7 +61,7 @@ DESCRIPTION
        7) four byte address termination record
        8) three byte address termination record
        9) two byte address termination record
-       
+
        o address
        is the start address of the data following, or in the case of
        a termination record, the start address of the image
@@ -71,7 +71,6 @@ DESCRIPTION
        is the sum of all the raw byte data in the record, from the length
        upwards, modulo 256 and subtracted from 255.
 
-
 SUBSECTION
        Symbol S-Record handling
 
@@ -101,7 +100,7 @@ EXAMPLE
 DESCRIPTION
        We allow symbols to be anywhere in the data stream - the module names
        are always ignored.
-               
+
 */
 
 #include "bfd.h"
@@ -170,8 +169,19 @@ srec_init ()
 
 /* The maximum number of bytes on a line is FF.  */
 #define MAXCHUNK 0xff
-/* The number of bytes we fit onto a line on output.  */
-#define CHUNK 16
+
+/* Default size for a CHUNK.  */
+#define DEFAULT_CHUNK 16
+
+/* The number of bytes we actually fit onto a line on output.
+   This variable can be modified by objcopy's --srec-len parameter.
+   For a 0x75 byte record you should set --srec-len=0x70.  */
+unsigned int Chunk = DEFAULT_CHUNK;
+
+/* The type of srec output (free or forced to S3).
+   This variable can be modified by objcopy's --srec-forceS3
+   parameter.  */
+boolean S3Forced = 0;
 
 /* When writing an S-record file, the S-records can not be output as
    they are seen.  This structure is used to hold them in memory.  */
@@ -867,19 +877,17 @@ srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
        return false;
       memcpy ((PTR) data, location, (size_t) bytes_to_do);
 
-      if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
-       {
-
-       }
+      /* Ff S3Forced is true then always select S3 records,
+        regardless of the siez of the addresses.  */
+      if (S3Forced)
+       tdata->type = 3;
+      else if ((section->lma + offset + bytes_to_do - 1) <= 0xffff)
+       ;  /* The default, S1, is OK.  */
       else if ((section->lma + offset + bytes_to_do - 1) <= 0xffffff
               && tdata->type <= 2)
-       {
-         tdata->type = 2;
-       }
+       tdata->type = 2;
       else
-       {
-         tdata->type = 3;
-       }
+       tdata->type = 3;
 
       entry->data = data;
       entry->where = section->lma + offset;
@@ -1006,8 +1014,8 @@ srec_write_section (abfd, tdata, list)
       bfd_vma address;
       unsigned int octets_this_chunk = list->size - octets_written;
 
-      if (octets_this_chunk > CHUNK)
-       octets_this_chunk = CHUNK;
+      if (octets_this_chunk > Chunk)
+       octets_this_chunk = Chunk;
 
       address = list->where + octets_written / bfd_octets_per_byte (abfd);
 
This page took 0.025306 seconds and 4 git commands to generate.