/* coffgrok.c
- Copyright (C) 1994, 95, 97, 1998 Free Software Foundation, Inc.
+ Copyright 1994, 1995, 1997, 1998, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation, Inc.
This file is part of GNU Binutils.
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. */
*/
-#include <bfd.h>
+#include "bfd.h"
+#include "libiberty.h"
#include "bucomm.h"
#include "coff/internal.h"
#include "../bfd/libcoff.h"
#include "coffgrok.h"
-int lofile = 1;
+static int lofile = 1;
static struct coff_scope *top_scope;
static struct coff_scope *file_scope;
static struct coff_ofile *ofile;
-struct coff_symbol *last_function_symbol;
-struct coff_type *last_function_type;
-struct coff_type *last_struct;
-struct coff_type *last_enum;
-struct coff_sfile *cur_sfile;
+static struct coff_symbol *last_function_symbol;
+static struct coff_type *last_function_type;
+static struct coff_type *last_struct;
+static struct coff_type *last_enum;
+static struct coff_sfile *cur_sfile;
static struct coff_symbol **tindex;
static struct coff_ptr_struct *rawsyms;
static int rawcount;
static bfd *abfd;
-extern char *xcalloc ();
-#define PTR_SIZE 4
-#define SHORT_SIZE 2
-#define INT_SIZE 4
-#define LONG_SIZE 4
-#define FLOAT_SIZE 4
-#define DOUBLE_SIZE 8
+
+#define PTR_SIZE 4
+#define SHORT_SIZE 2
+#define INT_SIZE 4
+#define LONG_SIZE 4
+#define FLOAT_SIZE 4
+#define DOUBLE_SIZE 8
#define INDEXOF(p) ((struct coff_ptr_struct *)(p)-(rawsyms))
+static struct coff_scope *empty_scope (void);
+static struct coff_symbol *empty_symbol (void);
+static void push_scope (int);
+static void pop_scope (void);
+static void do_sections_p1 (struct coff_ofile *);
+static void do_sections_p2 (struct coff_ofile *);
+static struct coff_where *do_where (int);
+static struct coff_line *do_lines (int, char *);
+static struct coff_type *do_type (int);
+static struct coff_visible *do_visible (int);
+static int do_define (int, struct coff_scope *);
+static struct coff_ofile *doit (void);
+
static struct coff_scope *
-empty_scope ()
+empty_scope (void)
{
struct coff_scope *l;
l = (struct coff_scope *) (xcalloc (sizeof (struct coff_scope), 1));
}
static struct coff_symbol *
-empty_symbol ()
+empty_symbol (void)
{
return (struct coff_symbol *) (xcalloc (sizeof (struct coff_symbol), 1));
}
/*int l;*/
static void
-push_scope (link)
- int link;
+push_scope (int link)
{
struct coff_scope *n = empty_scope ();
if (link)
}
static void
-pop_scope ()
+pop_scope (void)
{
top_scope = top_scope->parent;
}
static void
-do_sections_p1 (head)
- struct coff_ofile *head;
+do_sections_p1 (struct coff_ofile *head)
{
asection *section;
int idx;
if (relsize < 0)
bfd_fatal (bfd_get_filename (abfd));
if (relsize == 0)
- continue;
+ continue;
relpp = (arelent **) xmalloc (relsize);
relcount = bfd_canonicalize_reloc (abfd, section, relpp, syms);
if (relcount < 0)
if (strcmp (section->name, ".bss") == 0)
head->sections[i].data = 1;
head->sections[i].address = section->lma;
- head->sections[i].size = section->_raw_size;
+ head->sections[i].size = bfd_get_section_size (section);
head->sections[i].number = idx;
head->sections[i].nrelocs = section->reloc_count;
head->sections[i].relocs =
}
static void
-do_sections_p2 (head)
- struct coff_ofile *head;
+do_sections_p2 (struct coff_ofile *head)
{
asection *section;
for (section = abfd->sections; section; section = section->next)
}
static struct coff_where *
-do_where (i)
- int i;
+do_where (int i)
{
struct internal_syment *sym = &rawsyms[i].u.syment;
struct coff_where *where =
static
struct coff_line *
-do_lines (i, name)
- int i;
- char *name;
+do_lines (int i, char *name ATTRIBUTE_UNUSED)
{
struct coff_line *res = (struct coff_line *) xcalloc (sizeof (struct coff_line), 1);
asection *s;
/* These lines are for this function - so count them and stick them on */
int c = 0;
/* Find the linenumber of the top of the function, since coff linenumbers
- are relative to the start of the function. */
+ are relative to the start of the function. */
int start_line = rawsyms[i + 3].u.auxent.x_sym.x_misc.x_lnsz.x_lnno;
l++;
static
struct coff_type *
-do_type (i)
- int i;
+do_type (int i)
{
struct internal_syment *sym = &rawsyms[i].u.syment;
union internal_auxent *aux = &rawsyms[i + 1].u.auxent;
{
if (aux->x_sym.x_tagndx.p)
{
- /* Refering to a struct defined elsewhere */
+ /* Referring to a struct defined elsewhere */
res->type = coff_structref_type;
res->u.astructref.ref = tindex[INDEXOF (aux->x_sym.x_tagndx.p)];
res->size = res->u.astructref.ref ?
}
else
{
- /* No auxents - it's anonynmous */
+ /* No auxents - it's anonymous */
res->type = coff_structref_type;
res->u.astructref.ref = 0;
res->size = 0;
case T_ENUM:
if (aux->x_sym.x_tagndx.p)
{
- /* Refering to a enum defined elsewhere */
+ /* Referring to a enum defined elsewhere */
res->type = coff_enumref_type;
res->u.aenumref.ref = tindex[INDEXOF (aux->x_sym.x_tagndx.p)];
res->size = res->u.aenumref.ref->type->size;
}
static struct coff_visible *
-do_visible (i)
- int i;
+do_visible (int i)
{
struct internal_syment *sym = &rawsyms[i].u.syment;
struct coff_visible *visible =
}
static int
-do_define (i, b)
- int i;
- struct coff_scope *b;
+do_define (int i, struct coff_scope *b)
{
static int symbol_index;
struct internal_syment *sym = &rawsyms[i].u.syment;
static
struct coff_ofile *
-doit ()
+doit (void)
{
int i;
int infile = 0;
struct coff_ofile *head =
- (struct coff_ofile *) xmalloc (sizeof (struct coff_ofile));
+ (struct coff_ofile *) xmalloc (sizeof (struct coff_ofile));
ofile = head;
head->source_head = 0;
head->source_tail = 0;
}
struct coff_ofile *
-coff_grok (inabfd)
- bfd *inabfd;
+coff_grok (bfd *inabfd)
{
long storage;
struct coff_ofile *p;