X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=binutils%2Fsrconv.c;h=7abbb66c55c66c6d70546854fc3c0eabd9ba5a3e;hb=4ee959fb247a677b048ce3c59c1399c023a400d9;hp=3762a25e536822b5979e5c1425e9a6af6b0e0efc;hpb=b90efa5b79ac1524ec260f8eb89d1be37e0219a7;p=deliverable%2Fbinutils-gdb.git diff --git a/binutils/srconv.c b/binutils/srconv.c index 3762a25e53..7abbb66c55 100644 --- a/binutils/srconv.c +++ b/binutils/srconv.c @@ -167,7 +167,8 @@ checksum (FILE *ffile, unsigned char *ptr, int size, int ccode) last = !(ccode & 0xff00); if (size & 0x7) - abort (); + fatal (_("Checksum failure")); + ptr[0] = ccode | (last ? 0x80 : 0); ptr[1] = bytes + 1; @@ -178,7 +179,7 @@ checksum (FILE *ffile, unsigned char *ptr, int size, int ccode) ptr[bytes] = ~sum; if (fwrite (ptr, bytes + 1, 1, ffile) != 1) /* FIXME: Return error status. */ - abort (); + fatal (_("Failed to write checksum")); } @@ -218,7 +219,7 @@ writeINT (int n, unsigned char *ptr, int *idx, int size, FILE *ffile) ptr[byte + 3] = n >> 0; break; default: - abort (); + fatal (_("Unsupported integer write size: %d"), size); } *idx += size * 8; } @@ -304,7 +305,7 @@ wr_tr (void) if (fwrite (b, sizeof (b), 1, file) != 1) /* FIXME: Return error status. */ - abort (); + fatal (_("Failed to write TR block")); } static void @@ -395,7 +396,8 @@ wr_hd (struct coff_ofile *p) toolname = "C_H8/300S"; break; default: - abort(); + fatal (_("Unrecognized H8300 sub-architecture: %ld"), + bfd_get_mach (abfd)); } rnames = rname_h8300; break; @@ -412,7 +414,7 @@ wr_hd (struct coff_ofile *p) rnames = rname_sh; break; default: - abort (); + fatal (_("Unsupported architecture: %d"), bfd_get_arch (abfd)); } if (! (bfd_get_file_flags(abfd) & EXEC_P)) @@ -866,7 +868,7 @@ walk_tree_type_1 (struct coff_sfile *sfile, struct coff_symbol *symbol, break; default: - abort (); + fatal (_("Unrecognised type: %d"), type->type); } } @@ -995,7 +997,7 @@ walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBU return; default: - abort (); + fatal (_("Unrecognised coff symbol type: %d"), symbol->type->type); } if (symbol->where->where == coff_where_member_of_struct) @@ -1057,7 +1059,7 @@ walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBU break; default: - abort (); + fatal (_("Unrecognised coff symbol visibility: %d"), symbol->visible->type); } dsy.dlength = symbol->type->size; @@ -1083,7 +1085,7 @@ walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBU break; default: - abort (); + fatal (_("Unrecognised coff symbol location: %d"), symbol->where->where); } switch (symbol->where->where) @@ -1128,7 +1130,7 @@ walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBU break; default: - abort (); + fatal (_("Unrecognised coff symbol location: %d"), symbol->where->where); } if (symbol->where->where == coff_where_register) @@ -1157,7 +1159,7 @@ walk_tree_symbol (struct coff_sfile *sfile, struct coff_section *section ATTRIBU break; default: - abort (); + fatal (_("Unrecognised coff symbol visibility: %d"), symbol->visible->type); } dsy.sfn = 0; @@ -1202,6 +1204,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); } @@ -1460,7 +1464,7 @@ wr_cs (void) if (fwrite (b, sizeof (b), 1, file) != 1) /* FIXME: Return error status. */ - abort (); + fatal (_("Failed to write CS struct")); } /* Write out the SC records for a unit. Create an SC @@ -1703,6 +1707,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; @@ -1713,7 +1720,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; @@ -1772,6 +1778,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); @@ -1883,10 +1890,12 @@ main (int ac, char **av) printf ("ids %d %d\n", base1, base2); tree = coff_grok (abfd); + if (tree) + { + if (!noprescan) + prescan (tree); - if (!noprescan) - prescan (tree); - - wr_module (tree); + wr_module (tree); + } return 0; }