]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - bfd/srec.c
Use bool in bfd
[thirdparty/binutils-gdb.git] / bfd / srec.c
index baae280d73c3789eea5715ca7f358e5670e0b2a5..3ddb3c56e33c2fae3fb6dcc144ca1bdeb565c42d 100644 (file)
@@ -1,7 +1,5 @@
 /* BFD back-end for s-record objects.
-   Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
-   Free Software Foundation, Inc.
+   Copyright (C) 1990-2021 Free Software Foundation, Inc.
    Written by Steve Chamberlain of Cygnus Support <sac@cygnus.com>.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -96,7 +94,7 @@
          _start $14
          _etext $8036
          _edata $8036
-         _end $8036
+         _end $8036
        $$
 
    DESCRIPTION
@@ -131,12 +129,12 @@ static const char digs[] = "0123456789ABCDEF";
 /* The number of data 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;
+unsigned int _bfd_srec_len = DEFAULT_CHUNK;
 
 /* The type of srec output (free or forced to S3).
    This variable can be modified by objcopy's --srec-forceS3
    parameter.  */
-bfd_boolean S3Forced = FALSE;
+bool _bfd_srec_forceS3 = false;
 
 /* 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.  */
@@ -180,27 +178,27 @@ tdata_type;
 static void
 srec_init (void)
 {
-  static bfd_boolean inited = FALSE;
+  static bool inited = false;
 
   if (! inited)
     {
-      inited = TRUE;
+      inited = true;
       hex_init ();
     }
 }
 
 /* Set up the S-record tdata information.  */
 
-static bfd_boolean
+static bool
 srec_mkobject (bfd *abfd)
 {
   tdata_type *tdata;
 
   srec_init ();
 
-  tdata = bfd_alloc (abfd, sizeof (tdata_type));
+  tdata = (tdata_type *) bfd_alloc (abfd, sizeof (tdata_type));
   if (tdata == NULL)
-    return FALSE;
+    return false;
 
   abfd->tdata.srec_data = tdata;
   tdata->type = 1;
@@ -210,21 +208,21 @@ srec_mkobject (bfd *abfd)
   tdata->symtail = NULL;
   tdata->csymbols = NULL;
 
-  return TRUE;
+  return true;
 }
 
 /* Read a byte from an S record file.  Set *ERRORPTR if an error
    occurred.  Return EOF on error or end of file.  */
 
 static int
-srec_get_byte (bfd *abfd, bfd_boolean *errorptr)
+srec_get_byte (bfd *abfd, bool *errorptr)
 {
   bfd_byte c;
 
   if (bfd_bread (&c, (bfd_size_type) 1, abfd) != 1)
     {
       if (bfd_get_error () != bfd_error_file_truncated)
-       *errorptr = TRUE;
+       *errorptr = true;
       return EOF;
     }
 
@@ -239,7 +237,7 @@ static void
 srec_bad_byte (bfd *abfd,
               unsigned int lineno,
               int c,
-              bfd_boolean error)
+              bool error)
 {
   if (c == EOF)
     {
@@ -248,17 +246,18 @@ srec_bad_byte (bfd *abfd,
     }
   else
     {
-      char buf[10];
+      char buf[40];
 
       if (! ISPRINT (c))
-       sprintf (buf, "\\%03o", (unsigned int) c);
+       sprintf (buf, "\\%03o", (unsigned int) c & 0xff);
       else
        {
          buf[0] = c;
          buf[1] = '\0';
        }
-      (*_bfd_error_handler)
-       (_("%B:%d: Unexpected character `%s' in S-record file\n"),
+      _bfd_error_handler
+       /* xgettext:c-format */
+       (_("%pB:%d: unexpected character `%s' in S-record file"),
         abfd, lineno, buf);
       bfd_set_error (bfd_error_bad_value);
     }
@@ -266,14 +265,14 @@ srec_bad_byte (bfd *abfd,
 
 /* Add a new symbol found in an S-record file.  */
 
-static bfd_boolean
+static bool
 srec_new_symbol (bfd *abfd, const char *name, bfd_vma val)
 {
   struct srec_symbol *n;
 
-  n = bfd_alloc (abfd, sizeof (* n));
+  n = (struct srec_symbol *) bfd_alloc (abfd, sizeof (* n));
   if (n == NULL)
-    return FALSE;
+    return false;
 
   n->name = name;
   n->val = val;
@@ -287,18 +286,18 @@ srec_new_symbol (bfd *abfd, const char *name, bfd_vma val)
 
   ++abfd->symcount;
 
-  return TRUE;
+  return true;
 }
 
 /* Read the S record file and turn it into sections.  We create a new
    section for each contiguous set of bytes.  */
 
-static bfd_boolean
+static bool
 srec_scan (bfd *abfd)
 {
   int c;
   unsigned int lineno = 1;
-  bfd_boolean error = FALSE;
+  bool error = false;
   bfd_byte *buf = NULL;
   size_t bufsize = 0;
   asection *sec = NULL;
@@ -363,7 +362,7 @@ srec_scan (bfd *abfd)
                }
 
              alc = 10;
-             symbuf = bfd_malloc (alc + 1);
+             symbuf = (char *) bfd_malloc (alc + 1);
              if (symbuf == NULL)
                goto error_return;
 
@@ -378,7 +377,7 @@ srec_scan (bfd *abfd)
                      char *n;
 
                      alc *= 2;
-                     n = bfd_realloc (symbuf, alc + 1);
+                     n = (char *) bfd_realloc (symbuf, alc + 1);
                      if (n == NULL)
                        goto error_return;
                      p = n + (p - symbuf);
@@ -395,7 +394,7 @@ srec_scan (bfd *abfd)
                }
 
              *p++ = '\0';
-             symname = bfd_alloc (abfd, (bfd_size_type) (p - symbuf));
+             symname = (char *) bfd_alloc (abfd, (bfd_size_type) (p - symbuf));
              if (symname == NULL)
                goto error_return;
              strcpy (symname, symbuf);
@@ -454,8 +453,8 @@ srec_scan (bfd *abfd)
        case 'S':
          {
            file_ptr pos;
-           char hdr[3];
-           unsigned int bytes;
+           unsigned char hdr[3];
+           unsigned int bytes, min_bytes;
            bfd_vma address;
            bfd_byte *data;
            unsigned char check_sum;
@@ -478,11 +477,24 @@ srec_scan (bfd *abfd)
              }
 
            check_sum = bytes = HEX (hdr + 1);
+           min_bytes = 3;
+           if (hdr[0] == '2' || hdr[0] == '8')
+             min_bytes = 4;
+           else if (hdr[0] == '3' || hdr[0] == '7')
+             min_bytes = 5;
+           if (bytes < min_bytes)
+             {
+               /* xgettext:c-format */
+               _bfd_error_handler (_("%pB:%d: byte count %d too small"),
+                                   abfd, lineno, bytes);
+               bfd_set_error (bfd_error_bad_value);
+               goto error_return;
+             }
+
            if (bytes * 2 > bufsize)
              {
-               if (buf != NULL)
-                 free (buf);
-               buf = bfd_malloc ((bfd_size_type) bytes * 2);
+               free (buf);
+               buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
                if (buf == NULL)
                  goto error_return;
                bufsize = bytes * 2;
@@ -537,12 +549,12 @@ srec_scan (bfd *abfd)
                  {
                    char secbuf[20];
                    char *secname;
-                   bfd_size_type amt;
+                   size_t amt;
                    flagword flags;
 
                    sprintf (secbuf, ".sec%d", bfd_count_sections (abfd) + 1);
                    amt = strlen (secbuf) + 1;
-                   secname = bfd_alloc (abfd, amt);
+                   secname = (char *) bfd_alloc (abfd, amt);
                    strcpy (secname, secbuf);
                    flags = SEC_HAS_CONTENTS | SEC_LOAD | SEC_ALLOC;
                    sec = bfd_make_section_with_flags (abfd, secname, flags);
@@ -563,8 +575,9 @@ srec_scan (bfd *abfd)
                check_sum = 255 - (check_sum & 0xff);
                if (check_sum != HEX (data))
                  {
-                   (*_bfd_error_handler)
-                     (_("%B:%d: Bad checksum in S-record file\n"),
+                   _bfd_error_handler
+                     /* xgettext:c-format */
+                     (_("%pB:%d: bad checksum in S-record file"),
                       abfd, lineno);
                    bfd_set_error (bfd_error_bad_value);
                    goto error_return;
@@ -596,17 +609,16 @@ srec_scan (bfd *abfd)
                check_sum = 255 - (check_sum & 0xff);
                if (check_sum != HEX (data))
                  {
-                   (*_bfd_error_handler)
-                     (_("%B:%d: Bad checksum in S-record file\n"),
+                   _bfd_error_handler
+                     /* xgettext:c-format */
+                     (_("%pB:%d: bad checksum in S-record file"),
                       abfd, lineno);
                    bfd_set_error (bfd_error_bad_value);
                    goto error_return;
                  }
 
-               if (buf != NULL)
-                 free (buf);
-
-               return TRUE;
+               free (buf);
+               return true;
              }
          }
          break;
@@ -616,22 +628,18 @@ srec_scan (bfd *abfd)
   if (error)
     goto error_return;
 
-  if (buf != NULL)
-    free (buf);
-
-  return TRUE;
+  free (buf);
+  return true;
 
  error_return:
-  if (symbuf != NULL)
-    free (symbuf);
-  if (buf != NULL)
-    free (buf);
-  return FALSE;
+  free (symbuf);
+  free (buf);
+  return false;
 }
 
 /* Check whether an existing file is an S-record file.  */
 
-static const bfd_target *
+static bfd_cleanup
 srec_object_p (bfd *abfd)
 {
   void * tdata_save;
@@ -661,12 +669,12 @@ srec_object_p (bfd *abfd)
   if (abfd->symcount > 0)
     abfd->flags |= HAS_SYMS;
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 }
 
 /* Check whether an existing file is an S-record file with symbols.  */
 
-static const bfd_target *
+static bfd_cleanup
 symbolsrec_object_p (bfd *abfd)
 {
   void * tdata_save;
@@ -696,17 +704,17 @@ symbolsrec_object_p (bfd *abfd)
   if (abfd->symcount > 0)
     abfd->flags |= HAS_SYMS;
 
-  return abfd->xvec;
+  return _bfd_no_cleanup;
 }
 
 /* Read in the contents of a section in an S-record file.  */
 
-static bfd_boolean
+static bool
 srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
 {
   int c;
   bfd_size_type sofar = 0;
-  bfd_boolean error = FALSE;
+  bool error = false;
   bfd_byte *buf = NULL;
   size_t bufsize = 0;
 
@@ -736,9 +744,8 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
 
       if (bytes * 2 > bufsize)
        {
-         if (buf != NULL)
-           free (buf);
-         buf = bfd_malloc ((bfd_size_type) bytes * 2);
+         free (buf);
+         buf = (bfd_byte *) bfd_malloc ((bfd_size_type) bytes * 2);
          if (buf == NULL)
            goto error_return;
          bufsize = bytes * 2;
@@ -753,9 +760,8 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
        {
        default:
          BFD_ASSERT (sofar == section->size);
-         if (buf != NULL)
-           free (buf);
-         return TRUE;
+         free (buf);
+         return true;
 
        case '3':
          address = HEX (data);
@@ -778,9 +784,8 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
            {
              /* We've come to the end of this section.  */
              BFD_ASSERT (sofar == section->size);
-             if (buf != NULL)
-               free (buf);
-             return TRUE;
+             free (buf);
+             return true;
            }
 
          /* Don't consider checksum.  */
@@ -802,20 +807,17 @@ srec_read_section (bfd *abfd, asection *section, bfd_byte *contents)
 
   BFD_ASSERT (sofar == section->size);
 
-  if (buf != NULL)
-    free (buf);
-
-  return TRUE;
+  free (buf);
+  return true;
 
  error_return:
-  if (buf != NULL)
-    free (buf);
-  return FALSE;
+  free (buf);
+  return false;
 }
 
 /* Get the contents of a section in an S-record file.  */
 
-static bfd_boolean
+static bool
 srec_get_section_contents (bfd *abfd,
                           asection *section,
                           void * location,
@@ -823,58 +825,60 @@ srec_get_section_contents (bfd *abfd,
                           bfd_size_type count)
 {
   if (count == 0)
-    return TRUE;
+    return true;
 
   if (offset + count < count
       || offset + count > section->size)
     {
       bfd_set_error (bfd_error_invalid_operation);
-      return FALSE;
+      return false;
     }
 
   if (section->used_by_bfd == NULL)
     {
       section->used_by_bfd = bfd_alloc (abfd, section->size);
       if (section->used_by_bfd == NULL)
-       return FALSE;
+       return false;
 
-      if (! srec_read_section (abfd, section, section->used_by_bfd))
-       return FALSE;
+      if (! srec_read_section (abfd, section,
+                              (bfd_byte *) section->used_by_bfd))
+       return false;
     }
 
   memcpy (location, (bfd_byte *) section->used_by_bfd + offset,
          (size_t) count);
 
-  return TRUE;
+  return true;
 }
 
 /* Set the architecture.  We accept an unknown architecture here.  */
 
-static bfd_boolean
+static bool
 srec_set_arch_mach (bfd *abfd, enum bfd_architecture arch, unsigned long mach)
 {
   if (arch != bfd_arch_unknown)
     return bfd_default_set_arch_mach (abfd, arch, mach);
 
   abfd->arch_info = & bfd_default_arch_struct;
-  return TRUE;
+  return true;
 }
 
 /* We have to save up all the Srecords for a splurge before output.  */
 
-static bfd_boolean
+static bool
 srec_set_section_contents (bfd *abfd,
                           sec_ptr section,
                           const void * location,
                           file_ptr offset,
                           bfd_size_type bytes_to_do)
 {
+  int opb = bfd_octets_per_byte (abfd, NULL);
   tdata_type *tdata = abfd->tdata.srec_data;
   srec_data_list_type *entry;
 
-  entry = bfd_alloc (abfd, sizeof (* entry));
+  entry = (srec_data_list_type *) bfd_alloc (abfd, sizeof (* entry));
   if (entry == NULL)
-    return FALSE;
+    return false;
 
   if (bytes_to_do
       && (section->flags & SEC_ALLOC)
@@ -882,25 +886,25 @@ srec_set_section_contents (bfd *abfd,
     {
       bfd_byte *data;
 
-      data = bfd_alloc (abfd, bytes_to_do);
+      data = (bfd_byte *) bfd_alloc (abfd, bytes_to_do);
       if (data == NULL)
-       return FALSE;
+       return false;
       memcpy ((void *) data, location, (size_t) bytes_to_do);
 
-      /* Ff S3Forced is TRUE then always select S3 records,
-        regardless of the siez of the addresses.  */
-      if (S3Forced)
+      /* If _bfd_srec_forceS3 is TRUE then always select S3 records,
+        regardless of the size of the addresses.  */
+      if (_bfd_srec_forceS3)
        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
@@ -926,14 +930,14 @@ srec_set_section_contents (bfd *abfd,
            tdata->tail = entry;
        }
     }
-  return TRUE;
+  return true;
 }
 
 /* Write a record of type, of the supplied number of bytes. The
    supplied bytes and length don't have a checksum. That's worked out
    here.  */
 
-static bfd_boolean
+static bool
 srec_write_record (bfd *abfd,
                   unsigned int type,
                   bfd_vma address,
@@ -959,10 +963,12 @@ srec_write_record (bfd *abfd,
     case 7:
       TOHEX (dst, (address >> 24), check_sum);
       dst += 2;
+      /* Fall through.  */
     case 8:
     case 2:
       TOHEX (dst, (address >> 16), check_sum);
       dst += 2;
+      /* Fall through.  */
     case 9:
     case 1:
     case 0:
@@ -993,21 +999,21 @@ srec_write_record (bfd *abfd,
   return bfd_bwrite ((void *) buffer, wrlen, abfd) == wrlen;
 }
 
-static bfd_boolean
+static bool
 srec_write_header (bfd *abfd)
 {
-  unsigned int len = strlen (abfd->filename);
+  unsigned int len = strlen (bfd_get_filename (abfd));
 
   /* I'll put an arbitrary 40 char limit on header size.  */
   if (len > 40)
     len = 40;
 
   return srec_write_record (abfd, 0, (bfd_vma) 0,
-                           (bfd_byte *) abfd->filename,
-                           (bfd_byte *) abfd->filename + len);
+                           (bfd_byte *) bfd_get_filename (abfd),
+                           (bfd_byte *) bfd_get_filename (abfd) + len);
 }
 
-static bfd_boolean
+static bool
 srec_write_section (bfd *abfd,
                    tdata_type *tdata,
                    srec_data_list_type *list)
@@ -1021,43 +1027,44 @@ srec_write_section (bfd *abfd,
      have three, and S3 (tdata->type == 3) records have four.
      The total length can't exceed 255, and a zero data length will
      spin for a long time.  */
-  if (Chunk == 0)
-    Chunk = 1;
-  else if (Chunk > MAXCHUNK - tdata->type - 2)
-    Chunk = MAXCHUNK - tdata->type - 2;
+  if (_bfd_srec_len == 0)
+    _bfd_srec_len = 1;
+  else if (_bfd_srec_len > MAXCHUNK - tdata->type - 2)
+    _bfd_srec_len = MAXCHUNK - tdata->type - 2;
 
   while (octets_written < list->size)
     {
       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 > _bfd_srec_len)
+       octets_this_chunk = _bfd_srec_len;
 
-      address = list->where + octets_written / bfd_octets_per_byte (abfd);
+      address = list->where + (octets_written
+                              / bfd_octets_per_byte (abfd, NULL));
 
       if (! srec_write_record (abfd,
                               tdata->type,
                               address,
                               location,
                               location + octets_this_chunk))
-       return FALSE;
+       return false;
 
       octets_written += octets_this_chunk;
       location += octets_this_chunk;
     }
 
-  return TRUE;
+  return true;
 }
 
-static bfd_boolean
+static bool
 srec_write_terminator (bfd *abfd, tdata_type *tdata)
 {
   return srec_write_record (abfd, 10 - tdata->type,
                            abfd->start_address, NULL, NULL);
 }
 
-static bfd_boolean
+static bool
 srec_write_symbols (bfd *abfd)
 {
   /* Dump out the symbols of a bfd.  */
@@ -1069,17 +1076,20 @@ srec_write_symbols (bfd *abfd)
       bfd_size_type len;
       asymbol **table = bfd_get_outsymbols (abfd);
 
-      len = strlen (abfd->filename);
+      len = strlen (bfd_get_filename (abfd));
       if (bfd_bwrite ("$$ ", (bfd_size_type) 3, abfd) != 3
-         || bfd_bwrite (abfd->filename, len, abfd) != len
+         || bfd_bwrite (bfd_get_filename (abfd), len, abfd) != len
          || bfd_bwrite ("\r\n", (bfd_size_type) 2, abfd) != 2)
-       return FALSE;
+       return false;
 
       for (i = 0; i < count; i++)
        {
          asymbol *s = table[i];
+
          if (! bfd_is_local_label (abfd, s)
-             && (s->flags & BSF_DEBUGGING) == 0)
+             && (s->flags & BSF_DEBUGGING) == 0
+             && s->section != NULL
+             && s->section->output_section != NULL)
            {
              /* Just dump out non debug symbols.  */
              char buf[43], *p;
@@ -1087,7 +1097,7 @@ srec_write_symbols (bfd *abfd)
              len = strlen (s->name);
              if (bfd_bwrite ("  ", (bfd_size_type) 2, abfd) != 2
                  || bfd_bwrite (s->name, len, abfd) != len)
-               return FALSE;
+               return false;
 
              sprintf_vma (buf + 2, (s->value
                                     + s->section->output_section->lma
@@ -1102,17 +1112,17 @@ srec_write_symbols (bfd *abfd)
              *--p = ' ';
              len += 4;
              if (bfd_bwrite (p, len, abfd) != len)
-               return FALSE;
+               return false;
            }
        }
       if (bfd_bwrite ("$$ \r\n", (bfd_size_type) 5, abfd) != 5)
-       return FALSE;
+       return false;
     }
 
-  return TRUE;
+  return true;
 }
 
-static bfd_boolean
+static bool
 internal_srec_write_object_contents (bfd *abfd, int symbols)
 {
   tdata_type *tdata = abfd->tdata.srec_data;
@@ -1121,11 +1131,11 @@ internal_srec_write_object_contents (bfd *abfd, int symbols)
   if (symbols)
     {
       if (! srec_write_symbols (abfd))
-       return FALSE;
+       return false;
     }
 
   if (! srec_write_header (abfd))
-    return FALSE;
+    return false;
 
   /* Now wander though all the sections provided and output them.  */
   list = tdata->head;
@@ -1133,19 +1143,19 @@ internal_srec_write_object_contents (bfd *abfd, int symbols)
   while (list != (srec_data_list_type *) NULL)
     {
       if (! srec_write_section (abfd, tdata, list))
-       return FALSE;
+       return false;
       list = list->next;
     }
   return srec_write_terminator (abfd, tdata);
 }
 
-static bfd_boolean
+static bool
 srec_write_object_contents (bfd *abfd)
 {
   return internal_srec_write_object_contents (abfd, 0);
 }
 
-static bfd_boolean
+static bool
 symbolsrec_write_object_contents (bfd *abfd)
 {
   return internal_srec_write_object_contents (abfd, 1);
@@ -1181,7 +1191,7 @@ srec_canonicalize_symtab (bfd *abfd, asymbol **alocation)
       asymbol *c;
       struct srec_symbol *s;
 
-      csymbols = bfd_alloc (abfd, symcount * sizeof (asymbol));
+      csymbols = (asymbol *) bfd_alloc (abfd, symcount * sizeof (asymbol));
       if (csymbols == NULL)
        return -1;
       abfd->tdata.srec_data->csymbols = csymbols;
@@ -1235,33 +1245,40 @@ srec_print_symbol (bfd *abfd,
     }
 }
 
-#define        srec_close_and_cleanup                    _bfd_generic_close_and_cleanup
-#define srec_bfd_free_cached_info                 _bfd_generic_bfd_free_cached_info
-#define srec_new_section_hook                     _bfd_generic_new_section_hook
-#define srec_bfd_is_target_special_symbol         ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
-#define srec_bfd_is_local_label_name              bfd_generic_is_local_label_name
-#define srec_get_lineno                           _bfd_nosymbols_get_lineno
-#define srec_find_nearest_line                    _bfd_nosymbols_find_nearest_line
-#define srec_find_inliner_info                    _bfd_nosymbols_find_inliner_info
-#define srec_make_empty_symbol                    _bfd_generic_make_empty_symbol
-#define srec_bfd_make_debug_symbol                _bfd_nosymbols_bfd_make_debug_symbol
-#define srec_read_minisymbols                     _bfd_generic_read_minisymbols
-#define srec_minisymbol_to_symbol                 _bfd_generic_minisymbol_to_symbol
-#define srec_get_section_contents_in_window       _bfd_generic_get_section_contents_in_window
-#define srec_bfd_get_relocated_section_contents   bfd_generic_get_relocated_section_contents
-#define srec_bfd_relax_section                    bfd_generic_relax_section
-#define srec_bfd_gc_sections                      bfd_generic_gc_sections
-#define srec_bfd_merge_sections                   bfd_generic_merge_sections
-#define srec_bfd_is_group_section                 bfd_generic_is_group_section
-#define srec_bfd_discard_group                    bfd_generic_discard_group
-#define srec_section_already_linked               _bfd_generic_section_already_linked
-#define srec_bfd_define_common_symbol             bfd_generic_define_common_symbol
-#define srec_bfd_link_hash_table_create           _bfd_generic_link_hash_table_create
-#define srec_bfd_link_hash_table_free             _bfd_generic_link_hash_table_free
-#define srec_bfd_link_add_symbols                 _bfd_generic_link_add_symbols
-#define srec_bfd_link_just_syms                   _bfd_generic_link_just_syms
-#define srec_bfd_final_link                       _bfd_generic_final_link
-#define srec_bfd_link_split_section               _bfd_generic_link_split_section
+#define        srec_close_and_cleanup                    _bfd_generic_close_and_cleanup
+#define srec_bfd_free_cached_info                _bfd_generic_bfd_free_cached_info
+#define srec_new_section_hook                    _bfd_generic_new_section_hook
+#define srec_bfd_is_target_special_symbol        _bfd_bool_bfd_asymbol_false
+#define srec_bfd_is_local_label_name             bfd_generic_is_local_label_name
+#define srec_get_lineno                                  _bfd_nosymbols_get_lineno
+#define srec_find_nearest_line                   _bfd_nosymbols_find_nearest_line
+#define srec_find_line                           _bfd_nosymbols_find_line
+#define srec_find_inliner_info                   _bfd_nosymbols_find_inliner_info
+#define srec_make_empty_symbol                   _bfd_generic_make_empty_symbol
+#define srec_get_symbol_version_string           _bfd_nosymbols_get_symbol_version_string
+#define srec_bfd_make_debug_symbol               _bfd_nosymbols_bfd_make_debug_symbol
+#define srec_read_minisymbols                    _bfd_generic_read_minisymbols
+#define srec_minisymbol_to_symbol                _bfd_generic_minisymbol_to_symbol
+#define srec_get_section_contents_in_window      _bfd_generic_get_section_contents_in_window
+#define srec_bfd_get_relocated_section_contents          bfd_generic_get_relocated_section_contents
+#define srec_bfd_relax_section                   bfd_generic_relax_section
+#define srec_bfd_gc_sections                     bfd_generic_gc_sections
+#define srec_bfd_lookup_section_flags            bfd_generic_lookup_section_flags
+#define srec_bfd_merge_sections                          bfd_generic_merge_sections
+#define srec_bfd_is_group_section                bfd_generic_is_group_section
+#define srec_bfd_group_name                      bfd_generic_group_name
+#define srec_bfd_discard_group                   bfd_generic_discard_group
+#define srec_section_already_linked              _bfd_generic_section_already_linked
+#define srec_bfd_define_common_symbol            bfd_generic_define_common_symbol
+#define srec_bfd_link_hide_symbol                _bfd_generic_link_hide_symbol
+#define srec_bfd_define_start_stop               bfd_generic_define_start_stop
+#define srec_bfd_link_hash_table_create                  _bfd_generic_link_hash_table_create
+#define srec_bfd_link_add_symbols                _bfd_generic_link_add_symbols
+#define srec_bfd_link_just_syms                          _bfd_generic_link_just_syms
+#define srec_bfd_copy_link_hash_symbol_type      _bfd_generic_copy_link_hash_symbol_type
+#define srec_bfd_final_link                      _bfd_generic_final_link
+#define srec_bfd_link_split_section              _bfd_generic_link_split_section
+#define srec_bfd_link_check_relocs               _bfd_generic_link_check_relocs
 
 const bfd_target srec_vec =
 {
@@ -1277,6 +1294,8 @@ const bfd_target srec_vec =
   0,                           /* Leading underscore.  */
   ' ',                         /* AR_pad_char.  */
   16,                          /* AR_max_namelen.  */
+  0,                           /* match priority.  */
+  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16,  /* Data.  */
@@ -1291,16 +1310,16 @@ const bfd_target srec_vec =
     _bfd_dummy_target,
   },
   {
-    bfd_false,
+    _bfd_bool_bfd_false_error,
     srec_mkobject,
     _bfd_generic_mkarchive,
-    bfd_false,
+    _bfd_bool_bfd_false_error,
   },
   {                            /* bfd_write_contents.  */
-    bfd_false,
+    _bfd_bool_bfd_false_error,
     srec_write_object_contents,
     _bfd_write_archive_contents,
-    bfd_false,
+    _bfd_bool_bfd_false_error,
   },
 
   BFD_JUMP_TABLE_GENERIC (srec),
@@ -1332,6 +1351,8 @@ const bfd_target symbolsrec_vec =
   0,                           /* Leading underscore.  */
   ' ',                         /* AR_pad_char.  */
   16,                          /* AR_max_namelen.  */
+  0,                           /* match priority.  */
+  TARGET_KEEP_UNUSED_SECTION_SYMBOLS, /* keep unused section symbols.  */
   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   bfd_getb16, bfd_getb_signed_16, bfd_putb16,  /* Data.  */
@@ -1346,16 +1367,16 @@ const bfd_target symbolsrec_vec =
     _bfd_dummy_target,
   },
   {
-    bfd_false,
+    _bfd_bool_bfd_false_error,
     srec_mkobject,
     _bfd_generic_mkarchive,
-    bfd_false,
+    _bfd_bool_bfd_false_error,
   },
   {                            /* bfd_write_contents.  */
-    bfd_false,
+    _bfd_bool_bfd_false_error,
     symbolsrec_write_object_contents,
     _bfd_write_archive_contents,
-    bfd_false,
+    _bfd_bool_bfd_false_error,
   },
 
   BFD_JUMP_TABLE_GENERIC (srec),