/* stabs.c -- Parse COFF debugging information
- Copyright 1996, 2000, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1996-2019 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
- 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,
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"
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);
\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;
+ /* 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)
/* 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;
/* 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;
/* 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;
{
non_fatal (_("bfd_coff_get_syment failed: %s"),
bfd_errmsg (bfd_get_error ()));
+ free (fields);
return DEBUG_TYPE_NULL;
}
{
non_fatal (_("bfd_coff_get_auxent failed: %s"),
bfd_errmsg (bfd_get_error ()));
+ free (fields);
return DEBUG_TYPE_NULL;
}
psubaux = &auxent;
/* 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;
{
non_fatal (_("bfd_coff_get_syment failed: %s"),
bfd_errmsg (bfd_get_error ()));
+ free (names);
+ free (vals);
return DEBUG_TYPE_NULL;
}
/* 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)
{
/* 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)
{
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;
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;