gdb: resume ongoing step after handling fork or vfork
[deliverable/binutils-gdb.git] / binutils / rdcoff.c
index 249cc8596f2c6dc25fedeb81c34c83b5389cf8b2..a00e39ffa87813e92220f97bb1110cc652bfdb67 100644 (file)
@@ -1,12 +1,12 @@
 /* stabs.c -- Parse COFF debugging information
 /* stabs.c -- Parse COFF debugging information
-   Copyright 1996, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1996-2021 Free Software Foundation, Inc.
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
    This file is part of GNU Binutils.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    Written by Ian Lance Taylor <ian@cygnus.com>.
 
    This file is part of GNU Binutils.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
 
 /* This file contains code which parses COFF debugging information.  */
 
 
 /* This file contains code which parses COFF debugging information.  */
 
+#include "sysdep.h"
 #include "bfd.h"
 #include "coff/internal.h"
 #include "bfd.h"
 #include "coff/internal.h"
-#include "bucomm.h"
 #include "libiberty.h"
 #include "libiberty.h"
-#include "demangle.h"
+#include "bucomm.h"
 #include "debug.h"
 #include "budbg.h"
 
 #include "debug.h"
 #include "budbg.h"
 
@@ -83,35 +83,38 @@ struct coff_types
   debug_type basic[T_MAX + 1];
 };
 
   debug_type basic[T_MAX + 1];
 };
 
-static debug_type *coff_get_slot PARAMS ((struct coff_types *, int));
+static debug_type *coff_get_slot (struct coff_types *, long);
 static debug_type parse_coff_type
 static debug_type parse_coff_type
-  PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, long, int,
-          union internal_auxent *, boolean, PTR));
+  (bfd *, struct coff_symbols *, struct coff_types *, long, int,
+   union internal_auxent *, bool, void *);
 static debug_type parse_coff_base_type
 static debug_type parse_coff_base_type
-  PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, long, int,
-          union internal_auxent *, PTR));
+  (bfd *, struct coff_symbols *, struct coff_types *, long, int,
+   union internal_auxent *, void *);
 static debug_type parse_coff_struct_type
 static debug_type parse_coff_struct_type
-  PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, int,
-          union internal_auxent *, PTR));
+  (bfd *, struct coff_symbols *, struct coff_types *, int,
+   union internal_auxent *, void *);
 static debug_type parse_coff_enum_type
 static debug_type parse_coff_enum_type
-  PARAMS ((bfd *, struct coff_symbols *, struct coff_types *,
-          union internal_auxent *, PTR));
-static boolean parse_coff_symbol
-  PARAMS ((bfd *, struct coff_types *, asymbol *, long,
-          struct internal_syment *, PTR, debug_type, boolean));
-static boolean external_coff_symbol_p PARAMS ((int sym_class));
+  (bfd *, struct coff_symbols *, struct coff_types *,
+   union internal_auxent *, void *);
+static bool parse_coff_symbol
+  (bfd *, struct coff_types *, asymbol *, long, struct internal_syment *,
+   void *, debug_type, bool);
+static bool external_coff_symbol_p (int sym_class);
 \f
 /* Return the slot for a type.  */
 
 static debug_type *
 \f
 /* Return the slot for a type.  */
 
 static debug_type *
-coff_get_slot (types, indx)
-     struct coff_types *types;
-     int indx;
+coff_get_slot (struct coff_types *types, long indx)
 {
   struct coff_slots **pps;
 
   pps = &types->slots;
 
 {
   struct coff_slots **pps;
 
   pps = &types->slots;
 
+  /* PR 17512: file: 078-18333-0.001:0.1.
+     FIXME: The value of 1000 is a guess.  Maybe a better heuristic is needed.  */
+  if (indx / COFF_SLOTS > 1000)
+    fatal (_("Excessively large slot index: %lx"), indx);
+
   while (indx >= COFF_SLOTS)
     {
       if (*pps == NULL)
   while (indx >= COFF_SLOTS)
     {
       if (*pps == NULL)
@@ -135,16 +138,10 @@ coff_get_slot (types, indx)
 /* Parse a COFF type code in NTYPE.  */
 
 static debug_type
 /* Parse a COFF type code in NTYPE.  */
 
 static debug_type
-parse_coff_type (abfd, symbols, types, coff_symno, ntype, pauxent, useaux,
-                dhandle)
-     bfd *abfd;
-     struct coff_symbols *symbols;
-     struct coff_types *types;
-     long coff_symno;
-     int ntype;
-     union internal_auxent *pauxent;
-     boolean useaux;
-     PTR dhandle;
+parse_coff_type (bfd *abfd, struct coff_symbols *symbols,
+                struct coff_types *types, long coff_symno, int ntype,
+                union internal_auxent *pauxent, bool useaux,
+                void *dhandle)
 {
   debug_type type;
 
 {
   debug_type type;
 
@@ -238,18 +235,12 @@ parse_coff_type (abfd, symbols, types, coff_symno, ntype, pauxent, useaux,
 /* Parse a basic COFF type in NTYPE.  */
 
 static debug_type
 /* Parse a basic COFF type in NTYPE.  */
 
 static debug_type
-parse_coff_base_type (abfd, symbols, types, coff_symno, ntype, pauxent,
-                     dhandle)
-     bfd *abfd;
-     struct coff_symbols *symbols;
-     struct coff_types *types;
-     long coff_symno;
-     int ntype;
-     union internal_auxent *pauxent;
-     PTR dhandle;
+parse_coff_base_type (bfd *abfd, struct coff_symbols *symbols,
+                     struct coff_types *types, long coff_symno, int ntype,
+                     union internal_auxent *pauxent, void *dhandle)
 {
   debug_type ret;
 {
   debug_type ret;
-  boolean set_basic;
+  bool set_basic;
   const char *name;
   debug_type *slot;
 
   const char *name;
   debug_type *slot;
 
@@ -384,19 +375,15 @@ parse_coff_base_type (abfd, symbols, types, coff_symno, ntype, pauxent,
 /* Parse a struct type.  */
 
 static debug_type
 /* Parse a struct type.  */
 
 static debug_type
-parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, dhandle)
-     bfd *abfd;
-     struct coff_symbols *symbols;
-     struct coff_types *types;
-     int ntype;
-     union internal_auxent *pauxent;
-     PTR dhandle;
+parse_coff_struct_type (bfd *abfd, struct coff_symbols *symbols,
+                       struct coff_types *types, int ntype,
+                       union internal_auxent *pauxent, void *dhandle)
 {
   long symend;
   int alloc;
   debug_field *fields;
   int count;
 {
   long symend;
   int alloc;
   debug_field *fields;
   int count;
-  boolean done;
+  bool done;
 
   symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
 
 
   symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
 
@@ -422,6 +409,7 @@ parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, dhandle)
        {
          non_fatal (_("bfd_coff_get_syment failed: %s"),
                     bfd_errmsg (bfd_get_error ()));
        {
          non_fatal (_("bfd_coff_get_syment failed: %s"),
                     bfd_errmsg (bfd_get_error ()));
+         free (fields);
          return DEBUG_TYPE_NULL;
        }
 
          return DEBUG_TYPE_NULL;
        }
 
@@ -438,6 +426,7 @@ parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, dhandle)
            {
              non_fatal (_("bfd_coff_get_auxent failed: %s"),
                         bfd_errmsg (bfd_get_error ()));
            {
              non_fatal (_("bfd_coff_get_auxent failed: %s"),
                         bfd_errmsg (bfd_get_error ()));
+             free (fields);
              return DEBUG_TYPE_NULL;
            }
          psubaux = &auxent;
              return DEBUG_TYPE_NULL;
            }
          psubaux = &auxent;
@@ -495,19 +484,16 @@ parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, dhandle)
 /* Parse an enum type.  */
 
 static debug_type
 /* Parse an enum type.  */
 
 static debug_type
-parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle)
-     bfd *abfd;
-     struct coff_symbols *symbols;
-     struct coff_types *types ATTRIBUTE_UNUSED;
-     union internal_auxent *pauxent;
-     PTR dhandle;
+parse_coff_enum_type (bfd *abfd, struct coff_symbols *symbols,
+                     struct coff_types *types ATTRIBUTE_UNUSED,
+                     union internal_auxent *pauxent, void *dhandle)
 {
   long symend;
   int alloc;
   const char **names;
   bfd_signed_vma *vals;
   int count;
 {
   long symend;
   int alloc;
   const char **names;
   bfd_signed_vma *vals;
   int count;
-  boolean done;
+  bool done;
 
   symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
 
 
   symend = pauxent->x_sym.x_fcnary.x_fcn.x_endndx.l;
 
@@ -530,6 +516,8 @@ parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle)
        {
          non_fatal (_("bfd_coff_get_syment failed: %s"),
                     bfd_errmsg (bfd_get_error ()));
        {
          non_fatal (_("bfd_coff_get_syment failed: %s"),
                     bfd_errmsg (bfd_get_error ()));
+         free (names);
+         free (vals);
          return DEBUG_TYPE_NULL;
        }
 
          return DEBUG_TYPE_NULL;
        }
 
@@ -566,17 +554,11 @@ parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle)
 
 /* Handle a single COFF symbol.  */
 
 
 /* Handle a single COFF symbol.  */
 
-static boolean
-parse_coff_symbol (abfd, types, sym, coff_symno, psyment, dhandle, type,
-                  within_function)
-     bfd *abfd ATTRIBUTE_UNUSED;
-     struct coff_types *types;
-     asymbol *sym;
-     long coff_symno;
-     struct internal_syment *psyment;
-     PTR dhandle;
-     debug_type type;
-     boolean within_function;
+static bool
+parse_coff_symbol (bfd *abfd ATTRIBUTE_UNUSED, struct coff_types *types,
+                  asymbol *sym, long coff_symno,
+                  struct internal_syment *psyment, void *dhandle,
+                  debug_type type, bool within_function)
 {
   switch (psyment->n_sclass)
     {
 {
   switch (psyment->n_sclass)
     {
@@ -660,9 +642,8 @@ parse_coff_symbol (abfd, types, sym, coff_symno, psyment, dhandle, type,
 
 /* Determine if a symbol has external visibility.  */
 
 
 /* Determine if a symbol has external visibility.  */
 
-static boolean
-external_coff_symbol_p (sym_class)
-     int sym_class;
+static bool
+external_coff_symbol_p (int sym_class)
 {
   switch (sym_class)
     {
 {
   switch (sym_class)
     {
@@ -678,12 +659,8 @@ external_coff_symbol_p (sym_class)
 /* This is the main routine.  It looks through all the symbols and
    handles them.  */
 
 /* This is the main routine.  It looks through all the symbols and
    handles them.  */
 
-boolean
-parse_coff (abfd, syms, symcount, dhandle)
-     bfd *abfd;
-     asymbol **syms;
-     long symcount;
-     PTR dhandle;
+bool
+parse_coff (bfd *abfd, asymbol **syms, long symcount, void *dhandle)
 {
   struct coff_symbols symbols;
   struct coff_types types;
 {
   struct coff_symbols symbols;
   struct coff_types types;
@@ -694,7 +671,7 @@ parse_coff (abfd, syms, symcount, dhandle)
   int fntype;
   bfd_vma fnend;
   alent *linenos;
   int fntype;
   bfd_vma fnend;
   alent *linenos;
-  boolean within_function;
+  bool within_function;
   long this_coff_symno;
 
   symbols.syms = syms;
   long this_coff_symno;
 
   symbols.syms = syms;
@@ -839,7 +816,7 @@ parse_coff (abfd, syms, symcount, dhandle)
                  else
                    base = auxent.x_sym.x_misc.x_lnsz.x_lnno - 1;
 
                  else
                    base = auxent.x_sym.x_misc.x_lnsz.x_lnno - 1;
 
-                 addr = bfd_get_section_vma (abfd, bfd_get_section (sym));
+                 addr = bfd_section_vma (bfd_asymbol_section (sym));
 
                  ++linenos;
 
 
                  ++linenos;
 
This page took 0.048585 seconds and 4 git commands to generate.