Updated Portuguese translation for the BFD sub-directory
[binutils-gdb.git] / bfd / syms.c
index 7eafb7d17a9d51c2beb597bf39618d6b2cae1347..7daf741b7b61e27db12e04226599979226cc1f21 100644 (file)
@@ -1,5 +1,5 @@
 /* Generic symbol-table support for the BFD library.
 /* Generic symbol-table support for the BFD library.
-   Copyright (C) 1990-2018 Free Software Foundation, Inc.
+   Copyright (C) 1990-2021 Free Software Foundation, Inc.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
    Written by Cygnus Support.
 
    This file is part of BFD, the Binary File Descriptor library.
@@ -307,6 +307,9 @@ CODE_FRAGMENT
 .     with this name and type in use.  BSF_OBJECT must also be set.  *}
 .#define BSF_GNU_UNIQUE          (1 << 23)
 .
 .     with this name and type in use.  BSF_OBJECT must also be set.  *}
 .#define BSF_GNU_UNIQUE          (1 << 23)
 .
+.  {* This section symbol should be included in the symbol table.  *}
+.#define BSF_SECTION_SYM_USED    (1 << 24)
+.
 .  flagword flags;
 .
 .  {* A pointer to the section to which this symbol is
 .  flagword flags;
 .
 .  {* A pointer to the section to which this symbol is
@@ -361,23 +364,23 @@ FUNCTION
        bfd_is_local_label
 
 SYNOPSIS
        bfd_is_local_label
 
 SYNOPSIS
-       bfd_boolean bfd_is_local_label (bfd *abfd, asymbol *sym);
+       bool bfd_is_local_label (bfd *abfd, asymbol *sym);
 
 DESCRIPTION
        Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is
        a compiler generated local label, else return FALSE.
 */
 
 
 DESCRIPTION
        Return TRUE if the given symbol @var{sym} in the BFD @var{abfd} is
        a compiler generated local label, else return FALSE.
 */
 
-bfd_boolean
+bool
 bfd_is_local_label (bfd *abfd, asymbol *sym)
 {
   /* The BSF_SECTION_SYM check is needed for IA-64, where every label that
      starts with '.' is local.  This would accidentally catch section names
      if we didn't reject them here.  */
   if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_FILE | BSF_SECTION_SYM)) != 0)
 bfd_is_local_label (bfd *abfd, asymbol *sym)
 {
   /* The BSF_SECTION_SYM check is needed for IA-64, where every label that
      starts with '.' is local.  This would accidentally catch section names
      if we didn't reject them here.  */
   if ((sym->flags & (BSF_GLOBAL | BSF_WEAK | BSF_FILE | BSF_SECTION_SYM)) != 0)
-    return FALSE;
+    return false;
   if (sym->name == NULL)
   if (sym->name == NULL)
-    return FALSE;
+    return false;
   return bfd_is_local_label_name (abfd, sym->name);
 }
 
   return bfd_is_local_label_name (abfd, sym->name);
 }
 
@@ -386,7 +389,7 @@ FUNCTION
        bfd_is_local_label_name
 
 SYNOPSIS
        bfd_is_local_label_name
 
 SYNOPSIS
-       bfd_boolean bfd_is_local_label_name (bfd *abfd, const char *name);
+       bool bfd_is_local_label_name (bfd *abfd, const char *name);
 
 DESCRIPTION
        Return TRUE if a symbol with the name @var{name} in the BFD
 
 DESCRIPTION
        Return TRUE if a symbol with the name @var{name} in the BFD
@@ -404,7 +407,7 @@ FUNCTION
        bfd_is_target_special_symbol
 
 SYNOPSIS
        bfd_is_target_special_symbol
 
 SYNOPSIS
-       bfd_boolean bfd_is_target_special_symbol (bfd *abfd, asymbol *sym);
+       bool bfd_is_target_special_symbol (bfd *abfd, asymbol *sym);
 
 DESCRIPTION
        Return TRUE iff a symbol @var{sym} in the BFD @var{abfd} is something
 
 DESCRIPTION
        Return TRUE iff a symbol @var{sym} in the BFD @var{abfd} is something
@@ -437,7 +440,7 @@ FUNCTION
        bfd_set_symtab
 
 SYNOPSIS
        bfd_set_symtab
 
 SYNOPSIS
-       bfd_boolean bfd_set_symtab
+       bool bfd_set_symtab
          (bfd *abfd, asymbol **location, unsigned int count);
 
 DESCRIPTION
          (bfd *abfd, asymbol **location, unsigned int count);
 
 DESCRIPTION
@@ -446,18 +449,18 @@ DESCRIPTION
        will be written.
 */
 
        will be written.
 */
 
-bfd_boolean
+bool
 bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int symcount)
 {
   if (abfd->format != bfd_object || bfd_read_p (abfd))
     {
       bfd_set_error (bfd_error_invalid_operation);
 bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int symcount)
 {
   if (abfd->format != bfd_object || bfd_read_p (abfd))
     {
       bfd_set_error (bfd_error_invalid_operation);
-      return FALSE;
+      return false;
     }
 
     }
 
-  bfd_get_outsymbols (abfd) = location;
-  bfd_get_symcount (abfd) = symcount;
-  return TRUE;
+  abfd->outsymbols = location;
+  abfd->symcount = symcount;
+  return true;
 }
 
 /*
 }
 
 /*
@@ -538,7 +541,7 @@ DESCRIPTION
 asymbol *
 _bfd_generic_make_empty_symbol (bfd *abfd)
 {
 asymbol *
 _bfd_generic_make_empty_symbol (bfd *abfd)
 {
-  bfd_size_type amt = sizeof (asymbol);
+  size_t amt = sizeof (asymbol);
   asymbol *new_symbol = (asymbol *) bfd_zalloc (abfd, amt);
   if (new_symbol)
     new_symbol->the_bfd = abfd;
   asymbol *new_symbol = (asymbol *) bfd_zalloc (abfd, amt);
   if (new_symbol)
     new_symbol->the_bfd = abfd;
@@ -565,38 +568,23 @@ struct section_to_type
   char type;
 };
 
   char type;
 };
 
-/* Map section names to POSIX/BSD single-character symbol types.
+/* Map special section names to POSIX/BSD single-character symbol types.
    This table is probably incomplete.  It is sorted for convenience of
    adding entries.  Since it is so short, a linear search is used.  */
 static const struct section_to_type stt[] =
 {
    This table is probably incomplete.  It is sorted for convenience of
    adding entries.  Since it is so short, a linear search is used.  */
 static const struct section_to_type stt[] =
 {
-  {".bss", 'b'},
-  {"code", 't'},               /* MRI .text */
-  {".data", 'd'},
-  {"*DEBUG*", 'N'},
-  {".debug", 'N'},             /* MSVC's .debug (non-standard debug syms) */
   {".drectve", 'i'},           /* MSVC's .drective section */
   {".edata", 'e'},             /* MSVC's .edata (export) section */
   {".drectve", 'i'},           /* MSVC's .drective section */
   {".edata", 'e'},             /* MSVC's .edata (export) section */
-  {".fini", 't'},              /* ELF fini section */
   {".idata", 'i'},             /* MSVC's .idata (import) section */
   {".idata", 'i'},             /* MSVC's .idata (import) section */
-  {".init", 't'},              /* ELF init section */
   {".pdata", 'p'},             /* MSVC's .pdata (stack unwind) section */
   {".pdata", 'p'},             /* MSVC's .pdata (stack unwind) section */
-  {".rdata", 'r'},             /* Read only data.  */
-  {".rodata", 'r'},            /* Read only data.  */
-  {".sbss", 's'},              /* Small BSS (uninitialized data).  */
-  {".scommon", 'c'},           /* Small common.  */
-  {".sdata", 'g'},             /* Small initialized data.  */
-  {".text", 't'},
-  {"vars", 'd'},               /* MRI .data */
-  {"zerovars", 'b'},           /* MRI .bss */
   {0, 0}
 };
 
 /* Return the single-character symbol type corresponding to
    section S, or '?' for an unknown COFF section.
 
   {0, 0}
 };
 
 /* Return the single-character symbol type corresponding to
    section S, or '?' for an unknown COFF section.
 
-   Check for any leading string which matches, so .text5 returns
-   't' as well as .text */
+   Check for leading strings which match, followed by a number, '.',
+   or '$' so .idata5 matches the .idata entry.  */
 
 static char
 coff_section_type (const char *s)
 
 static char
 coff_section_type (const char *s)
@@ -604,8 +592,12 @@ coff_section_type (const char *s)
   const struct section_to_type *t;
 
   for (t = &stt[0]; t->section; t++)
   const struct section_to_type *t;
 
   for (t = &stt[0]; t->section; t++)
-    if (!strncmp (s, t->section, strlen (t->section)))
-      return t->type;
+    {
+      size_t len = strlen (t->section);
+      if (strncmp (s, t->section, len) == 0
+         && memchr (".$0123456789", s[len], 13) != 0)
+       return t->type;
+    }
 
   return '?';
 }
 
   return '?';
 }
@@ -614,7 +606,7 @@ coff_section_type (const char *s)
    SECTION, or '?' for an unknown section.  This uses section flags to
    identify sections.
 
    SECTION, or '?' for an unknown section.  This uses section flags to
    identify sections.
 
-   FIXME These types are unhandled: c, i, e, p.  If we handled these also,
+   FIXME These types are unhandled: e, i, p.  If we handled these also,
    we could perhaps obsolete coff_section_type.  */
 
 static char
    we could perhaps obsolete coff_section_type.  */
 
 static char
@@ -662,8 +654,17 @@ bfd_decode_symclass (asymbol *symbol)
 {
   char c;
 
 {
   char c;
 
+  /* Paranoia...  */
+  if (symbol == NULL || symbol->section == NULL)
+    return '?';
+
   if (symbol->section && bfd_is_com_section (symbol->section))
   if (symbol->section && bfd_is_com_section (symbol->section))
-    return 'C';
+    {
+      if (symbol->section->flags & SEC_SMALL_DATA)
+       return 'c';
+      else
+       return 'C';
+    }
   if (bfd_is_und_section (symbol->section))
     {
       if (symbol->flags & BSF_WEAK)
   if (bfd_is_und_section (symbol->section))
     {
       if (symbol->flags & BSF_WEAK)
@@ -730,10 +731,10 @@ DESCRIPTION
        Returns zero otherwise.
 
 SYNOPSIS
        Returns zero otherwise.
 
 SYNOPSIS
-       bfd_boolean bfd_is_undefined_symclass (int symclass);
+       bool bfd_is_undefined_symclass (int symclass);
 */
 
 */
 
-bfd_boolean
+bool
 bfd_is_undefined_symclass (int symclass)
 {
   return symclass == 'U' || symclass == 'w' || symclass == 'v';
 bfd_is_undefined_symclass (int symclass)
 {
   return symclass == 'U' || symclass == 'w' || symclass == 'v';
@@ -770,7 +771,7 @@ FUNCTION
        bfd_copy_private_symbol_data
 
 SYNOPSIS
        bfd_copy_private_symbol_data
 
 SYNOPSIS
-       bfd_boolean bfd_copy_private_symbol_data
+       bool bfd_copy_private_symbol_data
          (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
 
 DESCRIPTION
          (bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);
 
 DESCRIPTION
@@ -794,7 +795,7 @@ DESCRIPTION
 
 long
 _bfd_generic_read_minisymbols (bfd *abfd,
 
 long
 _bfd_generic_read_minisymbols (bfd *abfd,
-                              bfd_boolean dynamic,
+                              bool dynamic,
                               void **minisymsp,
                               unsigned int *sizep)
 {
                               void **minisymsp,
                               unsigned int *sizep)
 {
@@ -822,15 +823,21 @@ _bfd_generic_read_minisymbols (bfd *abfd,
   if (symcount < 0)
     goto error_return;
 
   if (symcount < 0)
     goto error_return;
 
-  *minisymsp = syms;
-  *sizep = sizeof (asymbol *);
-
+  if (symcount == 0)
+    /* We return 0 above when storage is 0.  Exit in the same state
+       here, so as to not complicate callers with having to deal with
+       freeing memory for zero symcount.  */
+    free (syms);
+  else
+    {
+      *minisymsp = syms;
+      *sizep = sizeof (asymbol *);
+    }
   return symcount;
 
  error_return:
   bfd_set_error (bfd_error_no_symbols);
   return symcount;
 
  error_return:
   bfd_set_error (bfd_error_no_symbols);
-  if (syms != NULL)
-    free (syms);
+  free (syms);
   return -1;
 }
 
   return -1;
 }
 
@@ -840,7 +847,7 @@ _bfd_generic_read_minisymbols (bfd *abfd,
 
 asymbol *
 _bfd_generic_minisymbol_to_symbol (bfd *abfd ATTRIBUTE_UNUSED,
 
 asymbol *
 _bfd_generic_minisymbol_to_symbol (bfd *abfd ATTRIBUTE_UNUSED,
-                                  bfd_boolean dynamic ATTRIBUTE_UNUSED,
+                                  bool dynamic ATTRIBUTE_UNUSED,
                                   const void *minisym,
                                   asymbol *sym ATTRIBUTE_UNUSED)
 {
                                   const void *minisym,
                                   asymbol *sym ATTRIBUTE_UNUSED)
 {
@@ -872,6 +879,7 @@ struct indexentry
   char *directory_name;
   char *file_name;
   char *function_name;
   char *directory_name;
   char *file_name;
   char *function_name;
+  int idx;
 };
 
 /* Compare two indexentry structures.  This is called via qsort.  */
 };
 
 /* Compare two indexentry structures.  This is called via qsort.  */
@@ -884,10 +892,9 @@ cmpindexentry (const void *a, const void *b)
 
   if (contestantA->val < contestantB->val)
     return -1;
 
   if (contestantA->val < contestantB->val)
     return -1;
-  else if (contestantA->val > contestantB->val)
+  if (contestantA->val > contestantB->val)
     return 1;
     return 1;
-  else
-    return 0;
+  return contestantA->idx - contestantB->idx;
 }
 
 /* A pointer to this structure is stored in *pinfo.  */
 }
 
 /* A pointer to this structure is stored in *pinfo.  */
@@ -920,12 +927,12 @@ struct stab_find_info
   char *filename;
 };
 
   char *filename;
 };
 
-bfd_boolean
+bool
 _bfd_stab_section_find_nearest_line (bfd *abfd,
                                     asymbol **symbols,
                                     asection *section,
                                     bfd_vma offset,
 _bfd_stab_section_find_nearest_line (bfd *abfd,
                                     asymbol **symbols,
                                     asection *section,
                                     bfd_vma offset,
-                                    bfd_boolean *pfound,
+                                    bool *pfound,
                                     const char **pfilename,
                                     const char **pfnname,
                                     unsigned int *pline,
                                     const char **pfilename,
                                     const char **pfnname,
                                     unsigned int *pline,
@@ -939,9 +946,9 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
   struct indexentry *indexentry;
   char *file_name;
   char *directory_name;
   struct indexentry *indexentry;
   char *file_name;
   char *directory_name;
-  bfd_boolean saw_line, saw_func;
+  bool saw_line, saw_func;
 
 
-  *pfound = FALSE;
+  *pfound = false;
   *pfilename = bfd_get_filename (abfd);
   *pfnname = NULL;
   *pline = 0;
   *pfilename = bfd_get_filename (abfd);
   *pfnname = NULL;
   *pline = 0;
@@ -972,7 +979,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
       if (info->stabsec == NULL || info->strsec == NULL)
        {
          /* No stabs debugging information.  */
       if (info->stabsec == NULL || info->strsec == NULL)
        {
          /* No stabs debugging information.  */
-         return TRUE;
+         return true;
        }
 
       stabsize = (info->stabsec->rawsize
        }
 
       stabsize = (info->stabsec->rawsize
@@ -992,7 +999,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
 
       info = (struct stab_find_info *) bfd_zalloc (abfd, amt);
       if (info == NULL)
 
       info = (struct stab_find_info *) bfd_zalloc (abfd, amt);
       if (info == NULL)
-       return FALSE;
+       return false;
 
       /* FIXME: When using the linker --split-by-file or
         --split-by-reloc options, it is possible for the .stab and
 
       /* FIXME: When using the linker --split-by-file or
         --split-by-reloc options, it is possible for the .stab and
@@ -1012,7 +1019,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
              /* No stabs debugging information.  Set *pinfo so that we
                 can return quickly in the info != NULL case above.  */
              *pinfo = info;
              /* No stabs debugging information.  Set *pinfo so that we
                 can return quickly in the info != NULL case above.  */
              *pinfo = info;
-             return TRUE;
+             return true;
            }
        }
 
            }
        }
 
@@ -1027,13 +1034,17 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
       info->stabs = (bfd_byte *) bfd_alloc (abfd, stabsize);
       info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
       if (info->stabs == NULL || info->strs == NULL)
       info->stabs = (bfd_byte *) bfd_alloc (abfd, stabsize);
       info->strs = (bfd_byte *) bfd_alloc (abfd, strsize);
       if (info->stabs == NULL || info->strs == NULL)
-       return FALSE;
+       return false;
 
       if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
                                      0, stabsize)
          || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
                                         0, strsize))
 
       if (! bfd_get_section_contents (abfd, info->stabsec, info->stabs,
                                      0, stabsize)
          || ! bfd_get_section_contents (abfd, info->strsec, info->strs,
                                         0, strsize))
-       return FALSE;
+       return false;
+
+      /* Stab strings ought to be nul terminated.  Ensure the last one
+        is, to prevent running off the end of the buffer.  */
+      info->strs[strsize - 1] = 0;
 
       /* If this is a relocatable object file, we have to relocate
         the entries in .stab.  This should always be simple 32 bit
 
       /* If this is a relocatable object file, we have to relocate
         the entries in .stab.  This should always be simple 32 bit
@@ -1041,17 +1052,16 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
         this should be no big deal.  */
       reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
       if (reloc_size < 0)
         this should be no big deal.  */
       reloc_size = bfd_get_reloc_upper_bound (abfd, info->stabsec);
       if (reloc_size < 0)
-       return FALSE;
+       return false;
       reloc_vector = (arelent **) bfd_malloc (reloc_size);
       if (reloc_vector == NULL && reloc_size != 0)
       reloc_vector = (arelent **) bfd_malloc (reloc_size);
       if (reloc_vector == NULL && reloc_size != 0)
-       return FALSE;
+       return false;
       reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
                                            symbols);
       if (reloc_count < 0)
        {
       reloc_count = bfd_canonicalize_reloc (abfd, info->stabsec, reloc_vector,
                                            symbols);
       if (reloc_count < 0)
        {
-         if (reloc_vector != NULL)
-           free (reloc_vector);
-         return FALSE;
+         free (reloc_vector);
+         return false;
        }
       if (reloc_count > 0)
        {
        }
       if (reloc_count > 0)
        {
@@ -1062,39 +1072,38 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
              arelent *r;
              unsigned long val;
              asymbol *sym;
              arelent *r;
              unsigned long val;
              asymbol *sym;
+             bfd_size_type octets;
 
              r = *pr;
              /* Ignore R_*_NONE relocs.  */
              if (r->howto->dst_mask == 0)
                continue;
 
 
              r = *pr;
              /* Ignore R_*_NONE relocs.  */
              if (r->howto->dst_mask == 0)
                continue;
 
+             octets = r->address * bfd_octets_per_byte (abfd, NULL);
              if (r->howto->rightshift != 0
                  || r->howto->size != 2
                  || r->howto->bitsize != 32
                  || r->howto->pc_relative
                  || r->howto->bitpos != 0
              if (r->howto->rightshift != 0
                  || r->howto->size != 2
                  || r->howto->bitsize != 32
                  || r->howto->pc_relative
                  || r->howto->bitpos != 0
-                 || r->howto->dst_mask != 0xffffffff)
+                 || r->howto->dst_mask != 0xffffffff
+                 || octets + 4 > stabsize)
                {
                  _bfd_error_handler
                {
                  _bfd_error_handler
-                   (_("Unsupported .stab relocation"));
+                   (_("unsupported .stab relocation"));
                  bfd_set_error (bfd_error_invalid_operation);
                  bfd_set_error (bfd_error_invalid_operation);
-                 if (reloc_vector != NULL)
-                   free (reloc_vector);
-                 return FALSE;
+                 free (reloc_vector);
+                 return false;
                }
 
                }
 
-             val = bfd_get_32 (abfd, info->stabs
-                               + r->address * bfd_octets_per_byte (abfd));
+             val = bfd_get_32 (abfd, info->stabs + octets);
              val &= r->howto->src_mask;
              sym = *r->sym_ptr_ptr;
              val += sym->value + sym->section->vma + r->addend;
              val &= r->howto->src_mask;
              sym = *r->sym_ptr_ptr;
              val += sym->value + sym->section->vma + r->addend;
-             bfd_put_32 (abfd, (bfd_vma) val, info->stabs
-                         + r->address * bfd_octets_per_byte (abfd));
+             bfd_put_32 (abfd, (bfd_vma) val, info->stabs + octets);
            }
        }
 
            }
        }
 
-      if (reloc_vector != NULL)
-       free (reloc_vector);
+      free (reloc_vector);
 
       /* First time through this function, build a table matching
         function VM addresses to stabs, then sort based on starting
 
       /* First time through this function, build a table matching
         function VM addresses to stabs, then sort based on starting
@@ -1137,14 +1146,14 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
        ++info->indextablesize;
 
       if (info->indextablesize == 0)
        ++info->indextablesize;
 
       if (info->indextablesize == 0)
-       return TRUE;
+       return true;
       ++info->indextablesize;
 
       amt = info->indextablesize;
       amt *= sizeof (struct indexentry);
       info->indextable = (struct indexentry *) bfd_alloc (abfd, amt);
       if (info->indextable == NULL)
       ++info->indextablesize;
 
       amt = info->indextablesize;
       amt *= sizeof (struct indexentry);
       info->indextable = (struct indexentry *) bfd_alloc (abfd, amt);
       if (info->indextable == NULL)
-       return FALSE;
+       return false;
 
       file_name = NULL;
       directory_name = NULL;
 
       file_name = NULL;
       directory_name = NULL;
@@ -1181,6 +1190,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
                  info->indextable[i].directory_name = directory_name;
                  info->indextable[i].file_name = file_name;
                  info->indextable[i].function_name = NULL;
                  info->indextable[i].directory_name = directory_name;
                  info->indextable[i].file_name = file_name;
                  info->indextable[i].function_name = NULL;
+                 info->indextable[i].idx = i;
                  ++i;
                }
 
                  ++i;
                }
 
@@ -1195,7 +1205,8 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
                {
                  nul_fun = stab;
                  nul_str = str;
                {
                  nul_fun = stab;
                  nul_str = str;
-                 if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+                 if (file_name >= (char *) info->strs + strsize
+                     || file_name < (char *) str)
                    file_name = NULL;
                  if (stab + STABSIZE + TYPEOFF < info->stabs + stabsize
                      && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO)
                    file_name = NULL;
                  if (stab + STABSIZE + TYPEOFF < info->stabs + stabsize
                      && *(stab + STABSIZE + TYPEOFF) == (bfd_byte) N_SO)
@@ -1206,7 +1217,8 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
                      directory_name = file_name;
                      file_name = ((char *) str
                                   + bfd_get_32 (abfd, stab + STRDXOFF));
                      directory_name = file_name;
                      file_name = ((char *) str
                                   + bfd_get_32 (abfd, stab + STRDXOFF));
-                     if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+                     if (file_name >= (char *) info->strs + strsize
+                         || file_name < (char *) str)
                        file_name = NULL;
                    }
                }
                        file_name = NULL;
                    }
                }
@@ -1217,7 +1229,8 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
              /* PR 17512: file: 0c680a1f.  */
              /* PR 17512: file: 5da8aec4.  */
              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
              /* PR 17512: file: 0c680a1f.  */
              /* PR 17512: file: 5da8aec4.  */
-             if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+             if (file_name >= (char *) info->strs + strsize
+                 || file_name < (char *) str)
                file_name = NULL;
              break;
 
                file_name = NULL;
              break;
 
@@ -1226,7 +1239,8 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
              function_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
              if (function_name == (char *) str)
                continue;
              function_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
              if (function_name == (char *) str)
                continue;
-             if (function_name >= (char *) info->strs + strsize)
+             if (function_name >= (char *) info->strs + strsize
+                 || function_name < (char *) str)
                function_name = NULL;
 
              nul_fun = NULL;
                function_name = NULL;
 
              nul_fun = NULL;
@@ -1236,6 +1250,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
              info->indextable[i].directory_name = directory_name;
              info->indextable[i].file_name = file_name;
              info->indextable[i].function_name = function_name;
              info->indextable[i].directory_name = directory_name;
              info->indextable[i].file_name = file_name;
              info->indextable[i].function_name = function_name;
+             info->indextable[i].idx = i;
              ++i;
              break;
            }
              ++i;
              break;
            }
@@ -1249,6 +1264,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
          info->indextable[i].directory_name = directory_name;
          info->indextable[i].file_name = file_name;
          info->indextable[i].function_name = NULL;
          info->indextable[i].directory_name = directory_name;
          info->indextable[i].file_name = file_name;
          info->indextable[i].function_name = NULL;
+         info->indextable[i].idx = i;
          ++i;
        }
 
          ++i;
        }
 
@@ -1258,6 +1274,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
       info->indextable[i].directory_name = NULL;
       info->indextable[i].file_name = NULL;
       info->indextable[i].function_name = NULL;
       info->indextable[i].directory_name = NULL;
       info->indextable[i].file_name = NULL;
       info->indextable[i].function_name = NULL;
+      info->indextable[i].idx = i;
       ++i;
 
       info->indextablesize = i;
       ++i;
 
       info->indextablesize = i;
@@ -1269,7 +1286,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
 
   /* We are passed a section relative offset.  The offsets in the
      stabs information are absolute.  */
 
   /* We are passed a section relative offset.  The offsets in the
      stabs information are absolute.  */
-  offset += bfd_get_section_vma (abfd, section);
+  offset += bfd_section_vma (section);
 
 #ifdef ENABLE_CACHING
   if (info->cached_indexentry != NULL
 
 #ifdef ENABLE_CACHING
   if (info->cached_indexentry != NULL
@@ -1309,7 +1326,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
        }
 
       if (indexentry == NULL)
        }
 
       if (indexentry == NULL)
-       return TRUE;
+       return true;
 
       stab = indexentry->stab + STABSIZE;
       file_name = indexentry->file_name;
 
       stab = indexentry->stab + STABSIZE;
       file_name = indexentry->file_name;
@@ -1318,14 +1335,14 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
   directory_name = indexentry->directory_name;
   str = indexentry->str;
 
   directory_name = indexentry->directory_name;
   str = indexentry->str;
 
-  saw_line = FALSE;
-  saw_func = FALSE;
+  saw_line = false;
+  saw_func = false;
   for (; stab < (indexentry+1)->stab; stab += STABSIZE)
     {
   for (; stab < (indexentry+1)->stab; stab += STABSIZE)
     {
-      bfd_boolean done;
+      bool done;
       bfd_vma val;
 
       bfd_vma val;
 
-      done = FALSE;
+      done = false;
 
       switch (stab[TYPEOFF])
        {
 
       switch (stab[TYPEOFF])
        {
@@ -1335,7 +1352,8 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
          if (val <= offset)
            {
              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
          if (val <= offset)
            {
              file_name = (char *) str + bfd_get_32 (abfd, stab + STRDXOFF);
-             if (file_name >= (char *) info->strs + strsize || file_name < (char *) str)
+             if (file_name >= (char *) info->strs + strsize
+                 || file_name < (char *) str)
                file_name = NULL;
              *pline = 0;
            }
                file_name = NULL;
              *pline = 0;
            }
@@ -1365,15 +1383,15 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
 #endif
            }
          if (val > offset)
 #endif
            }
          if (val > offset)
-           done = TRUE;
-         saw_line = TRUE;
+           done = true;
+         saw_line = true;
          break;
 
        case N_FUN:
        case N_SO:
          if (saw_func || saw_line)
          break;
 
        case N_FUN:
        case N_SO:
          if (saw_func || saw_line)
-           done = TRUE;
-         saw_func = TRUE;
+           done = true;
+         saw_func = true;
          break;
        }
 
          break;
        }
 
@@ -1381,7 +1399,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
        break;
     }
 
        break;
     }
 
-  *pfound = TRUE;
+  *pfound = true;
 
   if (file_name == NULL || IS_ABSOLUTE_PATH (file_name)
       || directory_name == NULL)
 
   if (file_name == NULL || IS_ABSOLUTE_PATH (file_name)
       || directory_name == NULL)
@@ -1403,7 +1421,7 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
          len = strlen (file_name) + 1;
          info->filename = (char *) bfd_alloc (abfd, dirlen + len);
          if (info->filename == NULL)
          len = strlen (file_name) + 1;
          info->filename = (char *) bfd_alloc (abfd, dirlen + len);
          if (info->filename == NULL)
-           return FALSE;
+           return false;
          memcpy (info->filename, directory_name, dirlen);
          memcpy (info->filename + dirlen, file_name, len);
        }
          memcpy (info->filename, directory_name, dirlen);
          memcpy (info->filename + dirlen, file_name, len);
        }
@@ -1425,5 +1443,120 @@ _bfd_stab_section_find_nearest_line (bfd *abfd,
       *pfnname = indexentry->function_name;
     }
 
       *pfnname = indexentry->function_name;
     }
 
-  return TRUE;
+  return true;
+}
+
+long
+_bfd_nosymbols_canonicalize_symtab (bfd *abfd ATTRIBUTE_UNUSED,
+                                   asymbol **location ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
+void
+_bfd_nosymbols_print_symbol (bfd *abfd ATTRIBUTE_UNUSED,
+                            void *afile ATTRIBUTE_UNUSED,
+                            asymbol *symbol ATTRIBUTE_UNUSED,
+                            bfd_print_symbol_type how ATTRIBUTE_UNUSED)
+{
+}
+
+void
+_bfd_nosymbols_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED,
+                               asymbol *sym ATTRIBUTE_UNUSED,
+                               symbol_info *ret ATTRIBUTE_UNUSED)
+{
+}
+
+const char *
+_bfd_nosymbols_get_symbol_version_string (bfd *abfd,
+                                         asymbol *symbol ATTRIBUTE_UNUSED,
+                                         bool base_p ATTRIBUTE_UNUSED,
+                                         bool *hidden ATTRIBUTE_UNUSED)
+{
+  return (const char *) _bfd_ptr_bfd_null_error (abfd);
+}
+
+bool
+_bfd_nosymbols_bfd_is_local_label_name (bfd *abfd ATTRIBUTE_UNUSED,
+                                       const char *name ATTRIBUTE_UNUSED)
+{
+  return false;
+}
+
+alent *
+_bfd_nosymbols_get_lineno (bfd *abfd, asymbol *sym ATTRIBUTE_UNUSED)
+{
+  return (alent *) _bfd_ptr_bfd_null_error (abfd);
+}
+
+bool
+_bfd_nosymbols_find_nearest_line
+    (bfd *abfd,
+     asymbol **symbols ATTRIBUTE_UNUSED,
+     asection *section ATTRIBUTE_UNUSED,
+     bfd_vma offset ATTRIBUTE_UNUSED,
+     const char **filename_ptr ATTRIBUTE_UNUSED,
+     const char **functionname_ptr ATTRIBUTE_UNUSED,
+     unsigned int *line_ptr ATTRIBUTE_UNUSED,
+     unsigned int *discriminator_ptr ATTRIBUTE_UNUSED)
+{
+  return _bfd_bool_bfd_false_error (abfd);
+}
+
+bool
+_bfd_nosymbols_find_line (bfd *abfd,
+                         asymbol **symbols ATTRIBUTE_UNUSED,
+                         asymbol *symbol ATTRIBUTE_UNUSED,
+                         const char **filename_ptr ATTRIBUTE_UNUSED,
+                         unsigned int *line_ptr ATTRIBUTE_UNUSED)
+{
+  return _bfd_bool_bfd_false_error (abfd);
+}
+
+bool
+_bfd_nosymbols_find_inliner_info
+    (bfd *abfd,
+     const char **filename_ptr ATTRIBUTE_UNUSED,
+     const char **functionname_ptr ATTRIBUTE_UNUSED,
+     unsigned int *line_ptr ATTRIBUTE_UNUSED)
+{
+  return _bfd_bool_bfd_false_error (abfd);
+}
+
+asymbol *
+_bfd_nosymbols_bfd_make_debug_symbol (bfd *abfd,
+                                     void *ptr ATTRIBUTE_UNUSED,
+                                     unsigned long sz ATTRIBUTE_UNUSED)
+{
+  return (asymbol *) _bfd_ptr_bfd_null_error (abfd);
+}
+
+long
+_bfd_nosymbols_read_minisymbols (bfd *abfd,
+                                bool dynamic ATTRIBUTE_UNUSED,
+                                void **minisymsp ATTRIBUTE_UNUSED,
+                                unsigned int *sizep ATTRIBUTE_UNUSED)
+{
+  return _bfd_long_bfd_n1_error (abfd);
+}
+
+asymbol *
+_bfd_nosymbols_minisymbol_to_symbol (bfd *abfd,
+                                    bool dynamic ATTRIBUTE_UNUSED,
+                                    const void *minisym ATTRIBUTE_UNUSED,
+                                    asymbol *sym ATTRIBUTE_UNUSED)
+{
+  return (asymbol *) _bfd_ptr_bfd_null_error (abfd);
+}
+
+long
+_bfd_nodynamic_get_synthetic_symtab (bfd *abfd,
+                                    long symcount ATTRIBUTE_UNUSED,
+                                    asymbol **syms ATTRIBUTE_UNUSED,
+                                    long dynsymcount ATTRIBUTE_UNUSED,
+                                    asymbol **dynsyms ATTRIBUTE_UNUSED,
+                                    asymbol **ret ATTRIBUTE_UNUSED)
+{
+  return _bfd_long_bfd_n1_error (abfd);
 }
 }