X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=binutils%2Frdcoff.c;h=4eb4d1579092b96a4c2721750204a8844c9e637f;hb=acdf84a65400f416c60a0c9c14953ba5a73fb0cd;hp=cca9b0e64be07a79aba35a771faa8f3461a7544c;hpb=b34976b65aea8f33690229600bbf4527ec3118e1;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/rdcoff.c b/binutils/rdcoff.c index cca9b0e64b..4eb4d15790 100644 --- a/binutils/rdcoff.c +++ b/binutils/rdcoff.c @@ -1,12 +1,12 @@ /* stabs.c -- Parse COFF debugging information - Copyright 1996, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1996-2020 Free Software Foundation, Inc. Written by Ian Lance Taylor . 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, @@ -16,15 +16,16 @@ 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. */ +#include "sysdep.h" #include "bfd.h" #include "coff/internal.h" -#include "bucomm.h" #include "libiberty.h" +#include "bucomm.h" #include "debug.h" #include "budbg.h" @@ -82,37 +83,38 @@ struct coff_types 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 - PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, long, int, - union internal_auxent *, bfd_boolean, PTR)); + (bfd *, struct coff_symbols *, struct coff_types *, long, int, + union internal_auxent *, bfd_boolean, void *); 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 - 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 - PARAMS ((bfd *, struct coff_symbols *, struct coff_types *, - union internal_auxent *, PTR)); + (bfd *, struct coff_symbols *, struct coff_types *, + union internal_auxent *, void *); static bfd_boolean parse_coff_symbol - PARAMS ((bfd *, struct coff_types *, asymbol *, long, - struct internal_syment *, PTR, debug_type, bfd_boolean)); -static bfd_boolean external_coff_symbol_p - PARAMS ((int sym_class)); + (bfd *, struct coff_types *, asymbol *, long, struct internal_syment *, + void *, debug_type, bfd_boolean); +static bfd_boolean external_coff_symbol_p (int sym_class); /* 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; + /* 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) @@ -136,16 +138,10 @@ coff_get_slot (types, indx) /* 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; - bfd_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, bfd_boolean useaux, + void *dhandle) { debug_type type; @@ -239,15 +235,9 @@ parse_coff_type (abfd, symbols, types, coff_symno, ntype, pauxent, useaux, /* 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; bfd_boolean set_basic; @@ -385,13 +375,9 @@ parse_coff_base_type (abfd, symbols, types, coff_symno, ntype, pauxent, /* 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; @@ -423,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 ())); + free (fields); return DEBUG_TYPE_NULL; } @@ -439,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 ())); + free (fields); return DEBUG_TYPE_NULL; } psubaux = &auxent; @@ -496,12 +484,9 @@ parse_coff_struct_type (abfd, symbols, types, ntype, pauxent, dhandle) /* 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; @@ -531,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 ())); + free (names); + free (vals); return DEBUG_TYPE_NULL; } @@ -568,16 +555,10 @@ parse_coff_enum_type (abfd, symbols, types, pauxent, dhandle) /* Handle a single COFF symbol. */ static bfd_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; - bfd_boolean within_function; +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, bfd_boolean within_function) { switch (psyment->n_sclass) { @@ -662,8 +643,7 @@ parse_coff_symbol (abfd, types, sym, coff_symno, psyment, dhandle, type, /* Determine if a symbol has external visibility. */ static bfd_boolean -external_coff_symbol_p (sym_class) - int sym_class; +external_coff_symbol_p (int sym_class) { switch (sym_class) { @@ -680,11 +660,7 @@ external_coff_symbol_p (sym_class) handles them. */ bfd_boolean -parse_coff (abfd, syms, symcount, dhandle) - bfd *abfd; - asymbol **syms; - long symcount; - PTR dhandle; +parse_coff (bfd *abfd, asymbol **syms, long symcount, void *dhandle) { struct coff_symbols symbols; struct coff_types types; @@ -840,7 +816,7 @@ parse_coff (abfd, syms, symcount, dhandle) 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;