X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=binutils%2Fsrconv.c;h=68ebc7845bdd9a83e2bfff94b9b3f62e2b71f373;hb=6e3b68350d29fde1dedc4772bbdce07ac3669f97;hp=a45437fd534e8b9065ece3484fb6c644d5d00109;hpb=2ee563b53258d390d7446e90a67f465d504ae44c;p=platform%2Fupstream%2Fbinutils.git diff --git a/binutils/srconv.c b/binutils/srconv.c index a45437f..68ebc78 100644 --- a/binutils/srconv.c +++ b/binutils/srconv.c @@ -1,5 +1,5 @@ /* srconv.c -- Sysroff conversion program - Copyright 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 + Copyright 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -42,61 +42,52 @@ static int addrsize; static char *toolname; static char **rnames; -static int get_member_id PARAMS ((int)); -static int get_ordinary_id PARAMS ((int)); -static char *section_translate PARAMS ((char *)); -static char *strip_suffix PARAMS ((char *)); -static void checksum PARAMS ((FILE *, char *, int, int)); -static void writeINT PARAMS ((int, char *, int *, int, FILE *)); -static void writeBITS PARAMS ((int, char *, int *, int)); -static void writeBARRAY PARAMS ((barray, char *, int *, int, FILE *)); -static void writeCHARS PARAMS ((char *, char *, int *, int, FILE *)); -static void wr_tr PARAMS ((void)); -static void wr_un PARAMS ((struct coff_ofile *, struct coff_sfile *, int, int)); -static void wr_hd PARAMS ((struct coff_ofile *)); -static void wr_sh PARAMS ((struct coff_ofile *, struct coff_section *)); -static void wr_ob PARAMS ((struct coff_ofile *, struct coff_section *)); -static void wr_rl PARAMS ((struct coff_ofile *, struct coff_section *)); -static void wr_object_body PARAMS ((struct coff_ofile *)); +static int get_member_id (int); +static int get_ordinary_id (int); +static char *section_translate (char *); +static char *strip_suffix (char *); +static void checksum (FILE *, char *, int, int); +static void writeINT (int, char *, int *, int, FILE *); +static void writeBITS (int, char *, int *, int); +static void writeBARRAY (barray, char *, int *, int, FILE *); +static void writeCHARS (char *, char *, int *, int, FILE *); +static void wr_tr (void); +static void wr_un (struct coff_ofile *, struct coff_sfile *, int, int); +static void wr_hd (struct coff_ofile *); +static void wr_sh (struct coff_ofile *, struct coff_section *); +static void wr_ob (struct coff_ofile *, struct coff_section *); +static void wr_rl (struct coff_ofile *, struct coff_section *); +static void wr_object_body (struct coff_ofile *); static void wr_dps_start - PARAMS ((struct coff_sfile *, struct coff_section *, struct coff_scope *, - int, int)); -static void wr_dps_end - PARAMS ((struct coff_section *, struct coff_scope *, int)); -static int *nints PARAMS ((int)); + (struct coff_sfile *, struct coff_section *, struct coff_scope *, int, int); +static void wr_dps_end (struct coff_section *, struct coff_scope *, int); +static int *nints (int); static void walk_tree_type_1 - PARAMS ((struct coff_sfile *, struct coff_symbol *, struct coff_type *, - int)); + (struct coff_sfile *, struct coff_symbol *, struct coff_type *, int); static void walk_tree_type - PARAMS ((struct coff_sfile *, struct coff_symbol *, struct coff_type *, - int)); + (struct coff_sfile *, struct coff_symbol *, struct coff_type *, int); static void walk_tree_symbol - PARAMS ((struct coff_sfile *, struct coff_section *, - struct coff_symbol *, int)); + (struct coff_sfile *, struct coff_section *, struct coff_symbol *, int); static void walk_tree_scope - PARAMS ((struct coff_section *, struct coff_sfile *, struct coff_scope *, - int, int)); -static void walk_tree_sfile - PARAMS ((struct coff_section *, struct coff_sfile *)); -static void wr_program_structure - PARAMS ((struct coff_ofile *, struct coff_sfile *)); -static void wr_du PARAMS ((struct coff_ofile *, struct coff_sfile *, int)); -static void wr_dus PARAMS ((struct coff_ofile *, struct coff_sfile *)); -static int find_base PARAMS ((struct coff_sfile *, struct coff_section *)); -static void wr_dln PARAMS ((struct coff_ofile *, struct coff_sfile *, int)); -static void wr_globals - PARAMS ((struct coff_ofile *, struct coff_sfile *, int)); -static void wr_debug PARAMS ((struct coff_ofile *)); -static void wr_cs PARAMS ((void)); -static int wr_sc PARAMS ((struct coff_ofile *, struct coff_sfile *)); -static void wr_er PARAMS ((struct coff_ofile *, struct coff_sfile *, int)); -static void wr_ed PARAMS ((struct coff_ofile *, struct coff_sfile *, int)); -static void wr_unit_info PARAMS ((struct coff_ofile *)); -static void wr_module PARAMS ((struct coff_ofile *)); -static int align PARAMS ((int)); -static void prescan PARAMS ((struct coff_ofile *)); -static void show_usage PARAMS ((FILE *, int)); -extern int main PARAMS ((int, char **)); + (struct coff_section *, struct coff_sfile *, struct coff_scope *, int, int); +static void walk_tree_sfile (struct coff_section *, struct coff_sfile *); +static void wr_program_structure (struct coff_ofile *, struct coff_sfile *); +static void wr_du (struct coff_ofile *, struct coff_sfile *, int); +static void wr_dus (struct coff_ofile *, struct coff_sfile *); +static int find_base (struct coff_sfile *, struct coff_section *); +static void wr_dln (struct coff_ofile *, struct coff_sfile *, int); +static void wr_globals (struct coff_ofile *, struct coff_sfile *, int); +static void wr_debug (struct coff_ofile *); +static void wr_cs (void); +static int wr_sc (struct coff_ofile *, struct coff_sfile *); +static void wr_er (struct coff_ofile *, struct coff_sfile *, int); +static void wr_ed (struct coff_ofile *, struct coff_sfile *, int); +static void wr_unit_info (struct coff_ofile *); +static void wr_module (struct coff_ofile *); +static int align (int); +static void prescan (struct coff_ofile *); +static void show_usage (FILE *, int); +extern int main (int, char **); static FILE *file; static bfd *abfd; @@ -118,8 +109,7 @@ static int base1 = 0x18; static int base2 = 0x2018; static int -get_member_id (x) - int x; +get_member_id (int x) { if (ids2[x]) return ids2[x]; @@ -129,8 +119,7 @@ get_member_id (x) } static int -get_ordinary_id (x) - int x; +get_ordinary_id (int x) { if (ids1[x]) return ids1[x]; @@ -139,8 +128,7 @@ get_ordinary_id (x) return ids1[x]; } static char * -section_translate (n) - char *n; +section_translate (char *n) { if (strcmp (n, ".text") == 0) return "P"; @@ -155,8 +143,7 @@ section_translate (n) static char * -strip_suffix (name) - char *name; +strip_suffix (char *name) { int i; char *res; @@ -171,11 +158,7 @@ strip_suffix (name) /* IT LEN stuff CS */ static void -checksum (file, ptr, size, code) - FILE *file; - char *ptr; - int size; - int code; +checksum (FILE *file, char *ptr, int size, int code) { int j; int last; @@ -198,12 +181,7 @@ checksum (file, ptr, size, code) static void -writeINT (n, ptr, idx, size, file) - int n; - char *ptr; - int *idx; - int size; - FILE *file; +writeINT (int n, char *ptr, int *idx, int size, FILE *file) { int byte = *idx / 8; @@ -244,11 +222,7 @@ writeINT (n, ptr, idx, size, file) } static void -writeBITS (val, ptr, idx, size) - int val; - char *ptr; - int *idx; - int size; +writeBITS (int val, char *ptr, int *idx, int size) { int byte = *idx / 8; int bit = *idx % 8; @@ -265,12 +239,8 @@ writeBITS (val, ptr, idx, size) } static void -writeBARRAY (data, ptr, idx, size, file) - barray data; - char *ptr; - int *idx; - int size ATTRIBUTE_UNUSED; - FILE *file; +writeBARRAY (barray data, char *ptr, int *idx, int size ATTRIBUTE_UNUSED, + FILE *file) { int i; @@ -280,12 +250,7 @@ writeBARRAY (data, ptr, idx, size, file) } static void -writeCHARS (string, ptr, idx, size, file) - char *string; - char *ptr; - int *idx; - int size; - FILE *file; +writeCHARS (char *string, char *ptr, int *idx, int size, FILE *file) { int i = *idx / 8; @@ -324,7 +289,7 @@ static char *rname_h8300[] = }; static void -wr_tr () +wr_tr (void) { /* The TR block is not normal - it doesn't have any contents. */ @@ -338,11 +303,8 @@ wr_tr () } static void -wr_un (ptr, sfile, first, nsecs) - struct coff_ofile *ptr; - struct coff_sfile *sfile; - int first; - int nsecs ATTRIBUTE_UNUSED; +wr_un (struct coff_ofile *ptr, struct coff_sfile *sfile, int first, + int nsecs ATTRIBUTE_UNUSED) { struct IT_un un; struct coff_symbol *s; @@ -387,8 +349,7 @@ wr_un (ptr, sfile, first, nsecs) } static void -wr_hd (p) - struct coff_ofile *p; +wr_hd (struct coff_ofile *p) { struct IT_hd hd; @@ -475,9 +436,7 @@ wr_hd (p) static void -wr_sh (p, sec) - struct coff_ofile *p ATTRIBUTE_UNUSED; - struct coff_section *sec; +wr_sh (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_section *sec) { struct IT_sh sh; sh.unit = 0; @@ -490,23 +449,21 @@ wr_sh (p, sec) static void -wr_ob (p, section) - struct coff_ofile *p ATTRIBUTE_UNUSED; - struct coff_section *section; +wr_ob (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_section *section) { bfd_size_type i; int first = 1; unsigned char stuff[200]; i = 0; - while (i < section->bfd_section->_raw_size) + while (i < bfd_get_section_size (section->bfd_section)) { struct IT_ob ob; int todo = 200; /* Copy in 200 byte lumps. */ ob.spare = 0; - if (i + todo > section->bfd_section->_raw_size) - todo = section->bfd_section->_raw_size - i; + if (i + todo > bfd_get_section_size (section->bfd_section)) + todo = bfd_get_section_size (section->bfd_section) - i; if (first) { @@ -553,9 +510,7 @@ wr_ob (p, section) } static void -wr_rl (ptr, sec) - struct coff_ofile *ptr ATTRIBUTE_UNUSED; - struct coff_section *sec; +wr_rl (struct coff_ofile *ptr ATTRIBUTE_UNUSED, struct coff_section *sec) { int nr = sec->nrelocs; int i; @@ -613,8 +568,7 @@ wr_rl (ptr, sec) } static void -wr_object_body (p) - struct coff_ofile *p; +wr_object_body (struct coff_ofile *p) { int i; @@ -627,12 +581,9 @@ wr_object_body (p) } static void -wr_dps_start (sfile, section, scope, type, nest) - struct coff_sfile *sfile; - struct coff_section *section ATTRIBUTE_UNUSED; - struct coff_scope *scope; - int type; - int nest; +wr_dps_start (struct coff_sfile *sfile, + struct coff_section *section ATTRIBUTE_UNUSED, + struct coff_scope *scope, int type, int nest) { struct IT_dps dps; @@ -667,10 +618,8 @@ wr_dps_start (sfile, section, scope, type, nest) } static void -wr_dps_end (section, scope, type) - struct coff_section *section ATTRIBUTE_UNUSED; - struct coff_scope *scope ATTRIBUTE_UNUSED; - int type; +wr_dps_end (struct coff_section *section ATTRIBUTE_UNUSED, + struct coff_scope *scope ATTRIBUTE_UNUSED, int type) { struct IT_dps dps; @@ -680,18 +629,14 @@ wr_dps_end (section, scope, type) } static int * -nints (x) - int x; +nints (int x) { return (int *) (xcalloc (sizeof (int), x)); } static void -walk_tree_type_1 (sfile, symbol, type, nest) - struct coff_sfile *sfile; - struct coff_symbol *symbol; - struct coff_type *type; - int nest; +walk_tree_type_1 (struct coff_sfile *sfile, struct coff_symbol *symbol, + struct coff_type *type, int nest) { switch (type->type) { @@ -962,11 +907,8 @@ walk_tree_type_1 (sfile, symbol, type, nest) */ static void -walk_tree_type (sfile, symbol, type, nest) - struct coff_sfile *sfile; - struct coff_symbol *symbol; - struct coff_type *type; - int nest; +walk_tree_type (struct coff_sfile *sfile, struct coff_symbol *symbol, + struct coff_type *type, int nest) { if (symbol->type->type == coff_function_type) { @@ -1012,11 +954,7 @@ walk_tree_type (sfile, symbol, type, nest) } static void -walk_tree_symbol (sfile, section, symbol, nest) - struct coff_sfile *sfile; - struct coff_section *section ATTRIBUTE_UNUSED; - struct coff_symbol *symbol; - int nest; +walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBUTE_UNUSED, struct coff_symbol *symbol, int nest) { struct IT_dsy dsy; @@ -1230,12 +1168,7 @@ walk_tree_symbol (sfile, section, symbol, nest) } static void -walk_tree_scope (section, sfile, scope, nest, type) - struct coff_section *section; - struct coff_sfile *sfile; - struct coff_scope *scope; - int nest; - int type; +walk_tree_scope (struct coff_section *section, struct coff_sfile *sfile, struct coff_scope *scope, int nest, int type) { struct coff_symbol *vars; struct coff_scope *child; @@ -1259,26 +1192,19 @@ walk_tree_scope (section, sfile, scope, nest, type) } static void -walk_tree_sfile (section, sfile) - struct coff_section *section; - struct coff_sfile *sfile; +walk_tree_sfile (struct coff_section *section, struct coff_sfile *sfile) { walk_tree_scope (section, sfile, sfile->scope, 0, BLOCK_TYPE_COMPUNIT); } static void -wr_program_structure (p, sfile) - struct coff_ofile *p; - struct coff_sfile *sfile; +wr_program_structure (struct coff_ofile *p, struct coff_sfile *sfile) { walk_tree_sfile (p->sections + 4, sfile); } static void -wr_du (p, sfile, n) - struct coff_ofile *p; - struct coff_sfile *sfile; - int n; +wr_du (struct coff_ofile *p, struct coff_sfile *sfile, int n) { struct IT_du du; int lim; @@ -1391,9 +1317,7 @@ wr_du (p, sfile, n) } static void -wr_dus (p, sfile) - struct coff_ofile *p ATTRIBUTE_UNUSED; - struct coff_sfile *sfile; +wr_dus (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_sfile *sfile) { struct IT_dus dus; @@ -1429,19 +1353,14 @@ wr_dus (p, sfile) .text section for the output file. */ static int -find_base (sfile, section) - struct coff_sfile *sfile; - struct coff_section *section; +find_base (struct coff_sfile *sfile, struct coff_section *section) { return sfile->section[section->number].low; } static void -wr_dln (p, sfile, n) - struct coff_ofile *p ATTRIBUTE_UNUSED; - struct coff_sfile *sfile; - int n ATTRIBUTE_UNUSED; - +wr_dln (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_sfile *sfile, + int n ATTRIBUTE_UNUSED) { #if 0 if (n == 0) @@ -1578,10 +1497,8 @@ wr_dln (p, sfile, n) /* Write the global symbols out to the debug info. */ static void -wr_globals (p, sfile, n) - struct coff_ofile *p; - struct coff_sfile *sfile; - int n ATTRIBUTE_UNUSED; +wr_globals (struct coff_ofile *p, struct coff_sfile *sfile, + int n ATTRIBUTE_UNUSED) { struct coff_symbol *sy; @@ -1601,8 +1518,7 @@ wr_globals (p, sfile, n) } static void -wr_debug (p) - struct coff_ofile *p; +wr_debug (struct coff_ofile *p) { struct coff_sfile *sfile; int n = 0; @@ -1623,7 +1539,7 @@ wr_debug (p) } static void -wr_cs () +wr_cs (void) { /* It seems that the CS struct is not normal - the size is wrong heres one I prepared earlier. */ @@ -1671,9 +1587,7 @@ wr_cs () if there isn't an equivalent one on the input. */ static int -wr_sc (ptr, sfile) - struct coff_ofile *ptr; - struct coff_sfile *sfile; +wr_sc (struct coff_ofile *ptr, struct coff_sfile *sfile) { int i; int scount = 0; @@ -1795,10 +1709,8 @@ wr_sc (ptr, sfile) /* Write out the ER records for a unit. */ static void -wr_er (ptr, sfile, first) - struct coff_ofile *ptr; - struct coff_sfile *sfile ATTRIBUTE_UNUSED; - int first; +wr_er (struct coff_ofile *ptr, struct coff_sfile *sfile ATTRIBUTE_UNUSED, + int first) { int idx = 0; struct coff_symbol *sym; @@ -1824,10 +1736,8 @@ wr_er (ptr, sfile, first) /* Write out the ED records for a unit. */ static void -wr_ed (ptr, sfile, first) - struct coff_ofile *ptr; - struct coff_sfile *sfile ATTRIBUTE_UNUSED; - int first; +wr_ed (struct coff_ofile *ptr, struct coff_sfile *sfile ATTRIBUTE_UNUSED, + int first) { struct coff_symbol *s; @@ -1866,8 +1776,7 @@ wr_ed (ptr, sfile, first) } static void -wr_unit_info (ptr) - struct coff_ofile *ptr; +wr_unit_info (struct coff_ofile *ptr) { struct coff_sfile *sfile; int first = 1; @@ -1894,8 +1803,7 @@ wr_unit_info (ptr) } static void -wr_module (p) - struct coff_ofile *p; +wr_module (struct coff_ofile *p) { wr_cs (); wr_hd (p); @@ -1906,8 +1814,7 @@ wr_module (p) } static int -align (x) - int x; +align (int x) { return (x + 3) & ~3; } @@ -1916,8 +1823,7 @@ align (x) ordinary defs - dunno why, but thats what hitachi does with 'em. */ static void -prescan (tree) - struct coff_ofile *tree; +prescan (struct coff_ofile *tree) { struct coff_symbol *s; struct coff_section *common_section; @@ -1945,9 +1851,7 @@ prescan (tree) char *program_name; static void -show_usage (file, status) - FILE *file; - int status; +show_usage (FILE *file, int status) { fprintf (file, _("Usage: %s [option(s)] in-file [out-file]\n"), program_name); fprintf (file, _("Convert a COFF object file into a SYSROFF object file\n")); @@ -1964,9 +1868,7 @@ show_usage (file, status) } int -main (ac, av) - int ac; - char *av[]; +main (int ac, char **av) { int opt; static struct option long_options[] =