X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fsrconv.c;h=a421f642e0be73f99a051e1457fab7df607cb219;hb=20135676fc4c3912297c313b3e0d3cbd6cc402e3;hp=c19c0ed75a8bcbada04520455dae682b945ad69a;hpb=c88f5b8e495889f5d281a17bd56340d9a0e4cff6;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/srconv.c b/binutils/srconv.c index c19c0ed75a..a421f642e0 100644 --- a/binutils/srconv.c +++ b/binutils/srconv.c @@ -1,5 +1,5 @@ /* srconv.c -- Sysroff conversion program - Copyright (C) 1994-2015 Free Software Foundation, Inc. + Copyright (C) 1994-2019 Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -43,52 +43,12 @@ static int addrsize; static char *toolname; static char **rnames; -static int get_member_id (int); -static int get_ordinary_id (int); -static char *section_translate (char *); -static char *strip_suffix (const char *); -static void checksum (FILE *, unsigned char *, int, int); -static void writeINT (int, unsigned char *, int *, int, FILE *); -static void writeBITS (int, unsigned char *, int *, int); -static void writeBARRAY (barray, unsigned char *, int *, int, FILE *); -static void writeCHARS (char *, unsigned 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 - (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 - (struct coff_sfile *, struct coff_symbol *, struct coff_type *, int); -static void walk_tree_type - (struct coff_sfile *, struct coff_symbol *, struct coff_type *, int); static void walk_tree_symbol (struct coff_sfile *, struct coff_section *, struct coff_symbol *, int); static void walk_tree_scope (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; @@ -459,14 +419,14 @@ wr_ob (struct coff_ofile *p ATTRIBUTE_UNUSED, struct coff_section *section) unsigned char stuff[200]; i = 0; - while (i < bfd_get_section_size (section->bfd_section)) + while (i < bfd_section_size (section->bfd_section)) { struct IT_ob ob; int todo = 200; /* Copy in 200 byte lumps. */ ob.spare = 0; - if (i + todo > bfd_get_section_size (section->bfd_section)) - todo = bfd_get_section_size (section->bfd_section) - i; + if (i + todo > bfd_section_size (section->bfd_section)) + todo = bfd_section_size (section->bfd_section) - i; if (first) { @@ -914,13 +874,14 @@ static void walk_tree_type (struct coff_sfile *sfile, struct coff_symbol *symbol, struct coff_type *type, int nest) { - if (symbol->type->type == coff_function_type) - { - struct IT_dty dty; + struct IT_dty dty; - dty.end = 0; - dty.neg = 0x1001; + dty.spare = 0; + dty.end = 0; + dty.neg = 0x1001; + if (symbol->type->type == coff_function_type) + { sysroff_swap_dty_out (file, &dty); walk_tree_type_1 (sfile, symbol, type, nest); dty.end = 1; @@ -946,10 +907,6 @@ walk_tree_type (struct coff_sfile *sfile, struct coff_symbol *symbol, } else { - struct IT_dty dty; - - dty.end = 0; - dty.neg = 0x1001; sysroff_swap_dty_out (file, &dty); walk_tree_type_1 (sfile, symbol, type, nest); dty.end = 1; @@ -1204,6 +1161,8 @@ walk_tree_sfile (struct coff_section *section, struct coff_sfile *sfile) static void wr_program_structure (struct coff_ofile *p, struct coff_sfile *sfile) { + if (p->nsections < 4) + return; walk_tree_sfile (p->sections + 4, sfile); } @@ -1705,6 +1664,9 @@ prescan (struct coff_ofile *otree) struct coff_symbol *s; struct coff_section *common_section; + if (otree->nsections < 3) + return; + /* Find the common section - always section 3. */ common_section = otree->sections + 3; @@ -1715,7 +1677,6 @@ prescan (struct coff_ofile *otree) if (s->visible->type == coff_vis_common) { struct coff_where *w = s->where; - /* s->visible->type = coff_vis_ext_def; leave it as common */ common_section->size = align (common_section->size); w->offset = common_section->size + common_section->address; @@ -1728,7 +1689,7 @@ prescan (struct coff_ofile *otree) char *program_name; -static void +ATTRIBUTE_NORETURN static void show_usage (FILE *ffile, int status) { fprintf (ffile, _("Usage: %s [option(s)] in-file [out-file]\n"), program_name); @@ -1774,6 +1735,7 @@ main (int ac, char **av) program_name = av[0]; xmalloc_set_program_name (program_name); + bfd_set_error_program_name (program_name); expandargv (&ac, &av);