Ignore:
Timestamp:
Aug 16, 2003, 6:59:22 PM (22 years ago)
Author:
bird
Message:

binutils v2.14 - offical sources.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/binutils/bfd/srec.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r608 r609  
    11/* BFD back-end for s-record objects.
    22   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    3    2000
     3   2000, 2001, 2002
    44   Free Software Foundation, Inc.
    55   Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
     
    109109#include "libbfd.h"
    110110#include "libiberty.h"
    111 #include <ctype.h>
     111#include "safe-ctype.h"
    112112
    113113static void srec_get_symbol_info PARAMS ((bfd *, asymbol *, symbol_info *));
     
    115115 PARAMS ((bfd *, PTR, asymbol *, bfd_print_symbol_type));
    116116static void srec_init PARAMS ((void));
    117 static boolean srec_mkobject PARAMS ((bfd *));
    118 static int srec_get_byte PARAMS ((bfd *, boolean *));
    119 static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, boolean));
    120 static boolean srec_scan PARAMS ((bfd *));
     117static bfd_boolean srec_mkobject PARAMS ((bfd *));
     118static int srec_get_byte PARAMS ((bfd *, bfd_boolean *));
     119static void srec_bad_byte PARAMS ((bfd *, unsigned int, int, bfd_boolean));
     120static bfd_boolean srec_scan PARAMS ((bfd *));
    121121static const bfd_target *srec_object_p PARAMS ((bfd *));
    122122static const bfd_target *symbolsrec_object_p PARAMS ((bfd *));
    123 static boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *));
    124 
    125 static boolean srec_write_record PARAMS ((bfd *, int, bfd_vma,
    126                                           const bfd_byte *,
    127                                           const bfd_byte *));
    128 static boolean srec_write_header PARAMS ((bfd *));
    129 static boolean srec_write_symbols PARAMS ((bfd *));
    130 static boolean srec_new_symbol PARAMS ((bfd *, const char *, bfd_vma));
    131 static boolean srec_get_section_contents
     123static bfd_boolean srec_read_section PARAMS ((bfd *, asection *, bfd_byte *));
     124
     125static bfd_boolean srec_write_record
     126  PARAMS ((bfd *, unsigned int, bfd_vma, const bfd_byte *, const bfd_byte *));
     127static bfd_boolean srec_write_header PARAMS ((bfd *));
     128static bfd_boolean srec_write_symbols PARAMS ((bfd *));
     129static bfd_boolean srec_new_symbol PARAMS ((bfd *, const char *, bfd_vma));
     130static bfd_boolean srec_get_section_contents
    132131  PARAMS ((bfd *, asection *, PTR, file_ptr, bfd_size_type));
    133 static boolean srec_set_arch_mach
     132static bfd_boolean srec_set_arch_mach
    134133  PARAMS ((bfd *, enum bfd_architecture, unsigned long));
    135 static boolean srec_set_section_contents
     134static bfd_boolean srec_set_section_contents
    136135  PARAMS ((bfd *, sec_ptr, PTR, file_ptr, bfd_size_type));
    137 static boolean internal_srec_write_object_contents PARAMS ((bfd *, int));
    138 static boolean srec_write_object_contents PARAMS ((bfd *));
    139 static boolean symbolsrec_write_object_contents PARAMS ((bfd *));
    140 static int srec_sizeof_headers PARAMS ((bfd *, boolean));
    141 static asymbol *srec_make_empty_symbol PARAMS ((bfd *));
     136static bfd_boolean internal_srec_write_object_contents PARAMS ((bfd *, int));
     137static bfd_boolean srec_write_object_contents PARAMS ((bfd *));
     138static bfd_boolean symbolsrec_write_object_contents PARAMS ((bfd *));
     139static int srec_sizeof_headers PARAMS ((bfd *, bfd_boolean));
    142140static long srec_get_symtab_upper_bound PARAMS ((bfd *));
    143141static long srec_get_symtab PARAMS ((bfd *, asymbol **));
     
    145143/* Macros for converting between hex and binary.  */
    146144
    147 static CONST char digs[] = "0123456789ABCDEF";
     145static const char digs[] = "0123456789ABCDEF";
    148146
    149147#define NIBBLE(x) hex_value(x)
     
    160158srec_init ()
    161159{
    162   static boolean inited = false;
    163 
    164   if (inited == false)
    165     {
    166       inited = true;
     160  static bfd_boolean inited = FALSE;
     161
     162  if (! inited)
     163    {
     164      inited = TRUE;
    167165      hex_init ();
    168166    }
    169167}
    170168
    171 /* The maximum number of bytes on a line is FF.  */
     169/* The maximum number of address+data+crc bytes on a line is FF.  */
    172170#define MAXCHUNK 0xff
    173171
     
    175173#define DEFAULT_CHUNK 16
    176174
    177 /* The number of bytes we actually fit onto a line on output.
     175/* The number of data bytes we actually fit onto a line on output.
    178176   This variable can be modified by objcopy's --srec-len parameter.
    179177   For a 0x75 byte record you should set --srec-len=0x70.  */
     
    183181   This variable can be modified by objcopy's --srec-forceS3
    184182   parameter.  */
    185 boolean S3Forced = 0;
     183bfd_boolean S3Forced = FALSE;
    186184
    187185/* When writing an S-record file, the S-records can not be output as
     
    222220tdata_type;
    223221
    224 static boolean srec_write_section PARAMS ((bfd *, tdata_type *,
    225                                            srec_data_list_type *));
    226 static boolean srec_write_terminator PARAMS ((bfd *, tdata_type *));
     222static bfd_boolean srec_write_section
     223  PARAMS ((bfd *, tdata_type *, srec_data_list_type *));
     224static bfd_boolean srec_write_terminator
     225  PARAMS ((bfd *, tdata_type *));
    227226
    228227/* Set up the S-record tdata information.  */
    229228
    230 static boolean
     229static bfd_boolean
    231230srec_mkobject (abfd)
    232231     bfd *abfd;
    233232{
     233  bfd_size_type amt;
     234  tdata_type *tdata;
     235
    234236  srec_init ();
    235237
    236   if (abfd->tdata.srec_data == NULL)
    237     {
    238       tdata_type *tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
    239       if (tdata == NULL)
    240         return false;
    241       abfd->tdata.srec_data = tdata;
    242       tdata->type = 1;
    243       tdata->head = NULL;
    244       tdata->tail = NULL;
    245       tdata->symbols = NULL;
    246       tdata->symtail = NULL;
    247       tdata->csymbols = NULL;
    248     }
    249 
    250   return true;
     238  amt = sizeof (tdata_type);
     239  tdata = (tdata_type *) bfd_alloc (abfd, amt);
     240  if (tdata == NULL)
     241    return FALSE;
     242
     243  abfd->tdata.srec_data = tdata;
     244  tdata->type = 1;
     245  tdata->head = NULL;
     246  tdata->tail = NULL;
     247  tdata->symbols = NULL;
     248  tdata->symtail = NULL;
     249  tdata->csymbols = NULL;
     250
     251  return TRUE;
    251252}
    252253
     
    257258srec_get_byte (abfd, errorptr)
    258259     bfd *abfd;
    259      boolean *errorptr;
     260     bfd_boolean *errorptr;
    260261{
    261262  bfd_byte c;
    262263
    263   if (bfd_read (&c, 1, 1, abfd) != 1)
     264  if (bfd_bread (&c, (bfd_size_type) 1, abfd) != 1)
    264265    {
    265266      if (bfd_get_error () != bfd_error_file_truncated)
    266         *errorptr = true;
     267        *errorptr = TRUE;
    267268      return EOF;
    268269    }
     
    280281     unsigned int lineno;
    281282     int c;
    282      boolean error;
     283     bfd_boolean error;
    283284{
    284285  if (c == EOF)
     
    291292      char buf[10];
    292293
    293       if (! isprint (c))
     294      if (! ISPRINT (c))
    294295        sprintf (buf, "\\%03o", (unsigned int) c);
    295296      else
     
    300301      (*_bfd_error_handler)
    301302        (_("%s:%d: Unexpected character `%s' in S-record file\n"),
    302          bfd_get_filename (abfd), lineno, buf);
     303         bfd_archive_filename (abfd), lineno, buf);
    303304      bfd_set_error (bfd_error_bad_value);
    304305    }
     
    307308/* Add a new symbol found in an S-record file.  */
    308309
    309 static boolean
     310static bfd_boolean
    310311srec_new_symbol (abfd, name, val)
    311312     bfd *abfd;
     
    314315{
    315316  struct srec_symbol *n;
    316 
    317   n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (struct srec_symbol));
     317  bfd_size_type amt = sizeof (struct srec_symbol);
     318
     319  n = (struct srec_symbol *) bfd_alloc (abfd, amt);
    318320  if (n == NULL)
    319     return false;
     321    return FALSE;
    320322
    321323  n->name = name;
     
    331333  ++abfd->symcount;
    332334
    333   return true;
     335  return TRUE;
    334336}
    335337
     
    337339   section for each contiguous set of bytes.  */
    338340
    339 static boolean
     341static bfd_boolean
    340342srec_scan (abfd)
    341343     bfd *abfd;
     
    343345  int c;
    344346  unsigned int lineno = 1;
    345   boolean error = false;
     347  bfd_boolean error = FALSE;
    346348  bfd_byte *buf = NULL;
    347349  size_t bufsize = 0;
     
    355357    {
    356358      /* We only build sections from contiguous S-records, so if this
    357         is not an S-record, then stop building a section.  */
     359        is not an S-record, then stop building a section.  */
    358360      if (c != 'S' && c != '\r' && c != '\n')
    359361        sec = NULL;
     
    390392          do
    391393            {
    392               unsigned int alc;
     394              bfd_size_type alc;
    393395              char *p, *symname;
    394396              bfd_vma symval;
     
    417419              *p++ = c;
    418420              while ((c = srec_get_byte (abfd, &error)) != EOF
    419                      && ! isspace (c))
     421                     && ! ISSPACE (c))
    420422                {
    421                   if ((unsigned int) (p - symbuf) >= alc)
     423                  if ((bfd_size_type) (p - symbuf) >= alc)
    422424                    {
    423425                      char *n;
     
    441443
    442444              *p++ = '\0';
    443               symname = bfd_alloc (abfd, p - symbuf);
     445              symname = bfd_alloc (abfd, (bfd_size_type) (p - symbuf));
    444446              if (symname == NULL)
    445447                goto error_return;
     
    504506            pos = bfd_tell (abfd) - 1;
    505507
    506             if (bfd_read (hdr, 1, 3, abfd) != 3)
     508            if (bfd_bread (hdr, (bfd_size_type) 3, abfd) != 3)
    507509              goto error_return;
    508510
     
    522524                if (buf != NULL)
    523525                  free (buf);
    524                 buf = (bfd_byte *) bfd_malloc (bytes * 2);
     526                buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
    525527                if (buf == NULL)
    526528                  goto error_return;
     
    528530              }
    529531
    530             if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
     532            if (bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2)
    531533              goto error_return;
    532534
     
    541543              case '5':
    542544                /* Prologue--ignore the file name, but stop building a
    543                    section at this point.  */
     545                   section at this point.  */
    544546                sec = NULL;
    545547                break;
     
    566568                  {
    567569                    /* This data goes at the end of the section we are
    568                        currently building.  */
     570                       currently building.  */
    569571                    sec->_raw_size += bytes;
    570572                  }
     
    573575                    char secbuf[20];
    574576                    char *secname;
     577                    bfd_size_type amt;
    575578
    576579                    sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
    577                     secname = (char *) bfd_alloc (abfd, strlen (secbuf) + 1);
     580                    amt = strlen (secbuf) + 1;
     581                    secname = (char *) bfd_alloc (abfd, amt);
    578582                    strcpy (secname, secbuf);
    579583                    sec = bfd_make_section (abfd, secname);
     
    609613                  free (buf);
    610614
    611                 return true;
     615                return TRUE;
    612616              }
    613617          }
     
    622626    free (buf);
    623627
    624   return true;
     628  return TRUE;
    625629
    626630 error_return:
     
    629633  if (buf != NULL)
    630634    free (buf);
    631   return false;
     635  return FALSE;
    632636}
    633637
     
    638642     bfd *abfd;
    639643{
     644  PTR tdata_save;
    640645  bfd_byte b[4];
    641646
     
    643648
    644649  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
    645       || bfd_read (b, 1, 4, abfd) != 4)
     650      || bfd_bread (b, (bfd_size_type) 4, abfd) != 4)
    646651    return NULL;
    647652
     
    652657    }
    653658
    654   if (! srec_mkobject (abfd)
    655       || ! srec_scan (abfd))
    656     return NULL;
     659  tdata_save = abfd->tdata.any;
     660  if (! srec_mkobject (abfd) || ! srec_scan (abfd))
     661    {
     662      if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
     663        bfd_release (abfd, abfd->tdata.any);
     664      abfd->tdata.any = tdata_save;
     665      return NULL;
     666    }
    657667
    658668  if (abfd->symcount > 0)
     
    668678     bfd *abfd;
    669679{
     680  PTR tdata_save;
    670681  char b[2];
    671682
     
    673684
    674685  if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0
    675       || bfd_read (b, 1, 2, abfd) != 2)
     686      || bfd_bread (b, (bfd_size_type) 2, abfd) != 2)
    676687    return NULL;
    677688
     
    682693    }
    683694
    684   if (! srec_mkobject (abfd)
    685       || ! srec_scan (abfd))
    686     return NULL;
     695  tdata_save = abfd->tdata.any;
     696  if (! srec_mkobject (abfd) || ! srec_scan (abfd))
     697    {
     698      if (abfd->tdata.any != tdata_save && abfd->tdata.any != NULL)
     699        bfd_release (abfd, abfd->tdata.any);
     700      abfd->tdata.any = tdata_save;
     701      return NULL;
     702    }
    687703
    688704  if (abfd->symcount > 0)
     
    694710/* Read in the contents of a section in an S-record file.  */
    695711
    696 static boolean
     712static bfd_boolean
    697713srec_read_section (abfd, section, contents)
    698714     bfd *abfd;
     
    702718  int c;
    703719  bfd_size_type sofar = 0;
    704   boolean error = false;
     720  bfd_boolean error = FALSE;
    705721  bfd_byte *buf = NULL;
    706722  size_t bufsize = 0;
     
    720736
    721737      /* This is called after srec_scan has already been called, so we
    722         ought to know the exact format.  */
     738        ought to know the exact format.  */
    723739      BFD_ASSERT (c == 'S');
    724740
    725       if (bfd_read (hdr, 1, 3, abfd) != 3)
     741      if (bfd_bread (hdr, (bfd_size_type) 3, abfd) != 3)
    726742        goto error_return;
    727743
     
    734750          if (buf != NULL)
    735751            free (buf);
    736           buf = (bfd_byte *) bfd_malloc (bytes * 2);
     752          buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
    737753          if (buf == NULL)
    738754            goto error_return;
     
    740756        }
    741757
    742       if (bfd_read (buf, 1, bytes * 2, abfd) != bytes * 2)
     758      if (bfd_bread (buf, (bfd_size_type) bytes * 2, abfd) != bytes * 2)
    743759        goto error_return;
    744760
     
    751767          if (buf != NULL)
    752768            free (buf);
    753           return true;
     769          return TRUE;
    754770
    755771        case '3':
     
    776792              if (buf != NULL)
    777793                free (buf);
    778               return true;
     794              return TRUE;
    779795            }
    780796
     
    801817    free (buf);
    802818
    803   return true;
     819  return TRUE;
    804820
    805821 error_return:
    806822  if (buf != NULL)
    807823    free (buf);
    808   return false;
     824  return FALSE;
    809825}
    810826
    811827/* Get the contents of a section in an S-record file.  */
    812828
    813 static boolean
     829static bfd_boolean
    814830srec_get_section_contents (abfd, section, location, offset, count)
    815831     bfd *abfd;
     
    822838    {
    823839      section->used_by_bfd = bfd_alloc (abfd, section->_raw_size);
    824       if (section->used_by_bfd == NULL
    825           && section->_raw_size != 0)
    826         return false;
     840      if (section->used_by_bfd == NULL && section->_raw_size != 0)
     841        return FALSE;
    827842
    828843      if (! srec_read_section (abfd, section, section->used_by_bfd))
    829         return false;
     844        return FALSE;
    830845    }
    831846
     
    833848          (size_t) count);
    834849
    835   return true;
     850  return TRUE;
    836851}
    837852
    838853/* Set the architecture.  We accept an unknown architecture here.  */
    839854
    840 static boolean
     855static bfd_boolean
    841856srec_set_arch_mach (abfd, arch, mach)
    842857     bfd *abfd;
     
    847862    {
    848863      abfd->arch_info = &bfd_default_arch_struct;
    849       return true;
     864      return TRUE;
    850865    }
    851866  return bfd_default_set_arch_mach (abfd, arch, mach);
     
    854869/* We have to save up all the Srecords for a splurge before output.  */
    855870
    856 static boolean
     871static bfd_boolean
    857872srec_set_section_contents (abfd, section, location, offset, bytes_to_do)
    858873     bfd *abfd;
     
    866881
    867882  entry = ((srec_data_list_type *)
    868            bfd_alloc (abfd, sizeof (srec_data_list_type)));
     883           bfd_alloc (abfd, (bfd_size_type) sizeof (srec_data_list_type)));
    869884  if (entry == NULL)
    870     return false;
     885    return FALSE;
    871886
    872887  if (bytes_to_do
     
    874889      && (section->flags & SEC_LOAD))
    875890    {
    876       bfd_byte *data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
     891      bfd_byte *data;
     892
     893      data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
    877894      if (data == NULL)
    878         return false;
     895        return FALSE;
    879896      memcpy ((PTR) data, location, (size_t) bytes_to_do);
    880897
    881       /* Ff S3Forced is true then always select S3 records,
     898      /* Ff S3Forced is TRUE then always select S3 records,
    882899         regardless of the siez of the addresses.  */
    883900      if (S3Forced)
     
    896913
    897914      /* Sort the records by address.  Optimize for the common case of
    898         adding a record to the end of the list.  */
     915        adding a record to the end of the list.  */
    899916      if (tdata->tail != NULL
    900917          && entry->where >= tdata->tail->where)
     
    918935        }
    919936    }
    920   return true;
     937  return TRUE;
    921938}
    922939
     
    925942   here.  */
    926943
    927 static boolean
     944static bfd_boolean
    928945srec_write_record (abfd, type, address, data, end)
    929946     bfd *abfd;
    930      int type;
     947     unsigned int type;
    931948     bfd_vma address;
    932949     const bfd_byte *data;
    933950     const bfd_byte *end;
    934951{
    935   char buffer[MAXCHUNK];
     952  char buffer[2 * MAXCHUNK + 6];
    936953  unsigned int check_sum = 0;
    937   CONST bfd_byte *src = data;
     954  const bfd_byte *src = data;
    938955  char *dst = buffer;
    939956  char *length;
     
    982999  *dst++ = '\n';
    9831000  wrlen = dst - buffer;
    984   if (bfd_write ((PTR) buffer, 1, wrlen, abfd) != wrlen)
    985     return false;
    986   return true;
    987 }
    988 
    989 static boolean
     1001  if (bfd_bwrite ((PTR) buffer, wrlen, abfd) != wrlen)
     1002    return FALSE;
     1003  return TRUE;
     1004}
     1005
     1006static bfd_boolean
    9901007srec_write_header (abfd)
    9911008     bfd *abfd;
    9921009{
    993   bfd_byte buffer[MAXCHUNK];
    994   bfd_byte *dst = buffer;
    995   unsigned int i;
     1010  unsigned int len = strlen (abfd->filename);
    9961011
    9971012  /* I'll put an arbitary 40 char limit on header size.  */
    998   for (i = 0; i < 40 && abfd->filename[i]; i++)
    999     *dst++ = abfd->filename[i];
    1000 
    1001   return srec_write_record (abfd, 0, 0, buffer, dst);
    1002 }
    1003 
    1004 static boolean
     1013  if (len > 40)
     1014    len = 40;
     1015
     1016  return srec_write_record (abfd, 0, (bfd_vma) 0,
     1017                            abfd->filename, abfd->filename + len);
     1018}
     1019
     1020static bfd_boolean
    10051021srec_write_section (abfd, tdata, list)
    10061022     bfd *abfd;
     
    10101026  unsigned int octets_written = 0;
    10111027  bfd_byte *location = list->data;
     1028
     1029  /* Validate number of data bytes to write.  The srec length byte
     1030     counts the address, data and crc bytes.  S1 (tdata->type == 1)
     1031     records have two address bytes, S2 (tdata->type == 2) records
     1032     have three, and S3 (tdata->type == 3) records have four.
     1033     The total length can't exceed 255, and a zero data length will
     1034     spin for a long time.  */
     1035  if (Chunk == 0)
     1036    Chunk = 1;
     1037  else if (Chunk > MAXCHUNK - tdata->type - 2)
     1038    Chunk = MAXCHUNK - tdata->type - 2;
    10121039
    10131040  while (octets_written < list->size)
     
    10261053                               location,
    10271054                               location + octets_this_chunk))
    1028         return false;
     1055        return FALSE;
    10291056
    10301057      octets_written += octets_this_chunk;
     
    10321059    }
    10331060
    1034   return true;
    1035 }
    1036 
    1037 static boolean
     1061  return TRUE;
     1062}
     1063
     1064static bfd_boolean
    10381065srec_write_terminator (abfd, tdata)
    10391066     bfd *abfd;
    10401067     tdata_type *tdata;
    10411068{
    1042   bfd_byte buffer[2];
    1043 
    10441069  return srec_write_record (abfd, 10 - tdata->type,
    1045                             abfd->start_address, buffer, buffer);
    1046 }
    1047 
    1048 static boolean
     1070                            abfd->start_address, NULL, NULL);
     1071}
     1072
     1073static bfd_boolean
    10491074srec_write_symbols (abfd)
    10501075     bfd *abfd;
    10511076{
    1052   char buffer[MAXCHUNK];
    10531077  /* Dump out the symbols of a bfd.  */
    10541078  int i;
     
    10571081  if (count)
    10581082    {
    1059       size_t len;
     1083      bfd_size_type len;
    10601084      asymbol **table = bfd_get_outsymbols (abfd);
    1061       sprintf (buffer, "$$ %s\r\n", abfd->filename);
    1062 
    1063       len = strlen (buffer);
    1064       if (bfd_write (buffer, len, 1, abfd) != len)
    1065         return false;
     1085      len = strlen (abfd->filename);
     1086      if (bfd_bwrite ("$$ ", (bfd_size_type) 3, abfd) != 3
     1087          || bfd_bwrite (abfd->filename, len, abfd) != len
     1088          || bfd_bwrite ("\r\n", (bfd_size_type) 2, abfd) != 2)
     1089        return FALSE;
    10661090
    10671091      for (i = 0; i < count; i++)
     
    10721096            {
    10731097              /* Just dump out non debug symbols.  */
    1074               bfd_size_type l;
    1075               char buf2[40], *p;
    1076 
    1077               sprintf_vma (buf2,
    1078                            s->value + s->section->output_section->lma
    1079                            + s->section->output_offset);
    1080               p = buf2;
     1098              char buf[43], *p;
     1099
     1100              len = strlen (s->name);
     1101              if (bfd_bwrite ("  ", (bfd_size_type) 2, abfd) != 2
     1102                  || bfd_bwrite (s->name, len, abfd) != len)
     1103                return FALSE;
     1104
     1105              sprintf_vma (buf + 2, (s->value
     1106                                     + s->section->output_section->lma
     1107                                     + s->section->output_offset));
     1108              p = buf + 2;
    10811109              while (p[0] == '0' && p[1] != 0)
    10821110                p++;
    1083               sprintf (buffer, "  %s $%s\r\n", s->name, p);
    1084               l = strlen (buffer);
    1085               if (bfd_write (buffer, l, 1, abfd) != l)
    1086                 return false;
     1111              len = strlen (p);
     1112              p[len] = '\r';
     1113              p[len + 1] = '\n';
     1114              *--p = '$';
     1115              *--p = ' ';
     1116              len += 4;
     1117              if (bfd_bwrite (p, len, abfd) != len)
     1118                return FALSE;
    10871119            }
    10881120        }
    1089       sprintf (buffer, "$$ \r\n");
    1090       len = strlen (buffer);
    1091       if (bfd_write (buffer, len, 1, abfd) != len)
    1092         return false;
    1093     }
    1094 
    1095   return true;
    1096 }
    1097 
    1098 static boolean
     1121      if (bfd_bwrite ("$$ \r\n", (bfd_size_type) 5, abfd) != 5)
     1122        return FALSE;
     1123    }
     1124
     1125  return TRUE;
     1126}
     1127
     1128static bfd_boolean
    10991129internal_srec_write_object_contents (abfd, symbols)
    11001130     bfd *abfd;
     
    11071137    {
    11081138      if (! srec_write_symbols (abfd))
    1109         return false;
     1139        return FALSE;
    11101140    }
    11111141
    11121142  if (! srec_write_header (abfd))
    1113     return false;
     1143    return FALSE;
    11141144
    11151145  /* Now wander though all the sections provided and output them.  */
     
    11191149    {
    11201150      if (! srec_write_section (abfd, tdata, list))
    1121         return false;
     1151        return FALSE;
    11221152      list = list->next;
    11231153    }
     
    11251155}
    11261156
    1127 static boolean
     1157static bfd_boolean
    11281158srec_write_object_contents (abfd)
    11291159     bfd *abfd;
     
    11321162}
    11331163
    1134 static boolean
     1164static bfd_boolean
    11351165symbolsrec_write_object_contents (abfd)
    11361166     bfd *abfd;
     
    11421172srec_sizeof_headers (abfd, exec)
    11431173     bfd *abfd ATTRIBUTE_UNUSED;
    1144      boolean exec ATTRIBUTE_UNUSED;
     1174     bfd_boolean exec ATTRIBUTE_UNUSED;
    11451175{
    11461176  return 0;
    1147 }
    1148 
    1149 static asymbol *
    1150 srec_make_empty_symbol (abfd)
    1151      bfd *abfd;
    1152 {
    1153   asymbol *new = (asymbol *) bfd_zalloc (abfd, sizeof (asymbol));
    1154   if (new)
    1155     new->the_bfd = abfd;
    1156   return new;
    11571177}
    11581178
     
    11731193     asymbol **alocation;
    11741194{
    1175   unsigned int symcount = bfd_get_symcount (abfd);
     1195  bfd_size_type symcount = bfd_get_symcount (abfd);
    11761196  asymbol *csymbols;
    11771197  unsigned int i;
     
    11851205      csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
    11861206      if (csymbols == NULL && symcount != 0)
    1187         return false;
     1207        return 0;
    11881208      abfd->tdata.srec_data->csymbols = csymbols;
    11891209
     
    12181238
    12191239static void
    1220 srec_print_symbol (ignore_abfd, afile, symbol, how)
    1221      bfd *ignore_abfd ATTRIBUTE_UNUSED;
     1240srec_print_symbol (abfd, afile, symbol, how)
     1241     bfd *abfd;
    12221242     PTR afile;
    12231243     asymbol *symbol;
     
    12311251      break;
    12321252    default:
    1233       bfd_print_symbol_vandf ((PTR) file, symbol);
     1253      bfd_print_symbol_vandf (abfd, (PTR) file, symbol);
    12341254      fprintf (file, " %-5s %s",
    12351255               symbol->section->name,
     
    12461266#define srec_get_lineno _bfd_nosymbols_get_lineno
    12471267#define srec_find_nearest_line _bfd_nosymbols_find_nearest_line
     1268#define srec_make_empty_symbol _bfd_generic_make_empty_symbol
    12481269#define srec_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
    12491270#define srec_read_minisymbols _bfd_generic_read_minisymbols
     
    12631284#define srec_bfd_relax_section bfd_generic_relax_section
    12641285#define srec_bfd_gc_sections bfd_generic_gc_sections
     1286#define srec_bfd_merge_sections bfd_generic_merge_sections
     1287#define srec_bfd_discard_group bfd_generic_discard_group
    12651288#define srec_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
     1289#define srec_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
    12661290#define srec_bfd_link_add_symbols _bfd_generic_link_add_symbols
     1291#define srec_bfd_link_just_syms _bfd_generic_link_just_syms
    12671292#define srec_bfd_final_link _bfd_generic_final_link
    12681293#define srec_bfd_link_split_section _bfd_generic_link_split_section
Note: See TracChangeset for help on using the changeset viewer.