X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gas%2Fecoff.c;h=40b129b877f55b7d7079be52a900c43787e82dde;hb=0d18235fb6cefd77bcb3645f3d334802452e693f;hp=55b290b8eb730836b28e6d21474fd6afc2766f71;hpb=86905619cc2bb66d7df6c9a0b2a9d23cc9402318;p=binutils-gdb.git diff --git a/gas/ecoff.c b/gas/ecoff.c index 55b290b8eb7..40b129b877f 100644 --- a/gas/ecoff.c +++ b/gas/ecoff.c @@ -1,5 +1,6 @@ /* ECOFF debugging support. - Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc. + Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Free Software Foundation, Inc. Contributed by Cygnus Support. This file was put together by Ian Lance Taylor . A good deal of it comes directly from mips-tfile.c, by Michael @@ -36,7 +37,7 @@ #include "coff/symconst.h" #include "aout/stab_gnu.h" -#include +#include "safe-ctype.h" /* Why isn't this in coff/sym.h? */ #define ST_RFDESCAPE 0xfff @@ -952,8 +953,7 @@ typedef struct efdr { } efdr_t; /* Pre-initialized extended file structure. */ -static const efdr_t init_file = -{ +static const efdr_t init_file = { { /* FDR structure */ 0, /* adr: memory address of beginning of file */ 0, /* rss: file name (of source, if known) */ @@ -1111,7 +1111,7 @@ static const type_info_t type_info_init = { /* Global hash table for the tags table and global table for file descriptors. */ -static varray_t file_desc = INIT_VARRAY (efdr_t); +static varray_t file_desc = INIT_VARRAY (efdr_t); static struct hash_control *tag_hash; @@ -1553,7 +1553,7 @@ add_string (vp, hash_tbl, str, ret_hash) register shash_t *hash_ptr; if (len >= PAGE_USIZE) - as_fatal (_("String too big (%lu bytes)"), len); + as_fatal (_("string too big (%lu bytes)"), len); hash_ptr = (shash_t *) hash_find (hash_tbl, str); if (hash_ptr == (shash_t *) NULL) @@ -1579,7 +1579,7 @@ add_string (vp, hash_tbl, str, ret_hash) err = hash_insert (hash_tbl, str, (char *) hash_ptr); if (err) - as_fatal (_("Inserting \"%s\" into string hash table: %s"), + as_fatal (_("inserting \"%s\" into string hash table: %s"), str, err); } @@ -2037,12 +2037,11 @@ get_tag (tag, sym, basic_type) { char *perm; - perm = xmalloc ((unsigned long) (strlen (tag) + 1)); - strcpy (perm, tag); + perm = xstrdup (tag); hash_ptr = allocate_shash (); err = hash_insert (tag_hash, perm, (char *) hash_ptr); if (err) - as_fatal (_("Inserting \"%s\" into tag hash table: %s"), + as_fatal (_("inserting \"%s\" into tag hash table: %s"), tag, err); hash_ptr->string = perm; } @@ -2190,7 +2189,7 @@ ecoff_get_cur_proc_sym () static void add_file (file_name, indx, fake) const char *file_name; /* file name */ - int indx; + int indx ATTRIBUTE_UNUSED; int fake; { register int first_ch; @@ -2217,9 +2216,11 @@ add_file (file_name, indx, fake) this if we see a .file directive with a string, since that implies that some sort of debugging information is being provided. */ - if (! symbol_table_frozen && debug_type == DEBUG_NONE) + if (! symbol_table_frozen && debug_type == DEBUG_UNSPECIFIED) debug_type = DEBUG_ECOFF; } + else if (debug_type == DEBUG_UNSPECIFIED) + debug_type = DEBUG_NONE; #ifndef NO_LISTING if (listing) @@ -2296,7 +2297,7 @@ add_file (file_name, indx, fake) (shash_t **)0); if (strlen (file_name) > PAGE_USIZE - 2) - as_fatal (_("Filename goes over one page boundary.")); + as_fatal (_("filename goes over one page boundary")); /* Push the start of the filename. We assume that the filename will be stored at string offset 1. */ @@ -2336,7 +2337,7 @@ ecoff_new_file (name) /* This is a hand coded assembler file, so automatically turn on debugging information. */ - if (debug_type == DEBUG_NONE) + if (debug_type == DEBUG_UNSPECIFIED) debug_type = DEBUG_ECOFF; } @@ -2424,7 +2425,7 @@ st_to_string (symbol_type) void ecoff_directive_begin (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char name_end; @@ -2462,7 +2463,7 @@ ecoff_directive_begin (ignore) void ecoff_directive_bend (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char name_end; @@ -2521,7 +2522,7 @@ static int coff_inside_enumeration; void ecoff_directive_def (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char name_end; @@ -2536,15 +2537,15 @@ ecoff_directive_def (ignore) if (coff_sym_name != (char *) NULL) as_warn (_(".def pseudo-op used inside of .def/.endef; ignored")); else if (*name == '\0') - as_warn (_("Empty symbol name in .def; ignored")); + as_warn (_("empty symbol name in .def; ignored")); else { if (coff_sym_name != (char *) NULL) free (coff_sym_name); if (coff_tag != (char *) NULL) free (coff_tag); - coff_sym_name = (char *) xmalloc ((unsigned long) (strlen (name) + 1)); - strcpy (coff_sym_name, name); + + coff_sym_name = xstrdup (name); coff_type = type_info_init; coff_storage_class = sc_Nil; coff_symbol_typ = st_Nil; @@ -2567,7 +2568,7 @@ ecoff_directive_def (ignore) void ecoff_directive_dim (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int dimens[N_TQ]; int i; @@ -2589,7 +2590,7 @@ ecoff_directive_dim (ignore) { if (*input_line_pointer != '\n' && *input_line_pointer != ';') - as_warn (_("Badly formed .dim directive")); + as_warn (_("badly formed .dim directive")); break; } } @@ -2602,7 +2603,7 @@ ecoff_directive_dim (ignore) { if (coff_type.num_dims >= N_TQ) { - as_warn (_("Too many .dim entries")); + as_warn (_("too many .dim entries")); break; } coff_type.dimensions[coff_type.num_dims] = dimens[i]; @@ -2617,7 +2618,7 @@ ecoff_directive_dim (ignore) void ecoff_directive_scl (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { long val; @@ -2642,7 +2643,7 @@ ecoff_directive_scl (ignore) void ecoff_directive_size (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int sizes[N_TQ]; int i; @@ -2664,7 +2665,7 @@ ecoff_directive_size (ignore) { if (*input_line_pointer != '\n' && *input_line_pointer != ';') - as_warn (_("Badly formed .size directive")); + as_warn (_("badly formed .size directive")); break; } } @@ -2677,7 +2678,7 @@ ecoff_directive_size (ignore) { if (coff_type.num_sizes >= N_TQ) { - as_warn (_("Too many .size entries")); + as_warn (_("too many .size entries")); break; } coff_type.sizes[coff_type.num_sizes] = sizes[i]; @@ -2692,7 +2693,7 @@ ecoff_directive_size (ignore) void ecoff_directive_type (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { long val; tq_t *tq_ptr; @@ -2718,7 +2719,7 @@ ecoff_directive_type (ignore) /* FIXME: We could handle this by setting the continued bit. There would still be a limit: the .type argument can not be infinite. */ - as_warn (_("The type of %s is too complex; it will be simplified"), + as_warn (_("the type of %s is too complex; it will be simplified"), coff_sym_name); break; } @@ -2761,7 +2762,7 @@ ecoff_directive_type (ignore) void ecoff_directive_tag (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char name_end; @@ -2776,8 +2777,7 @@ ecoff_directive_tag (ignore) name = input_line_pointer; name_end = get_symbol_end (); - coff_tag = (char *) xmalloc ((unsigned long) (strlen (name) + 1)); - strcpy (coff_tag, name); + coff_tag = xstrdup (name); *input_line_pointer = name_end; @@ -2789,7 +2789,7 @@ ecoff_directive_tag (ignore) void ecoff_directive_val (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { expressionS exp; @@ -2824,7 +2824,7 @@ ecoff_directive_val (ignore) void ecoff_directive_endef (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; symint_t indx; @@ -2860,7 +2860,7 @@ ecoff_directive_endef (ignore) if (coff_type.num_sizes != 1 || diff < 0) { - as_warn (_("Bad COFF debugging info")); + as_warn (_("bad COFF debugging information")); return; } @@ -2909,7 +2909,7 @@ ecoff_directive_endef (ignore) { if (coff_tag == (char *) NULL) { - as_warn (_("No tag specified for %s"), name); + as_warn (_("no tag specified for %s"), name); return; } @@ -2941,7 +2941,7 @@ ecoff_directive_endef (ignore) if (coff_type.num_sizes - coff_type.num_dims - coff_type.extra_sizes != 1) { - as_warn (_("Bad COFF debugging information")); + as_warn (_("bad COFF debugging information")); return; } else @@ -3004,11 +3004,10 @@ ecoff_directive_endef (ignore) void ecoff_directive_end (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char name_end; - register int ch; symbolS *ent; if (cur_file_ptr == (efdr_t *) NULL) @@ -3028,8 +3027,7 @@ ecoff_directive_end (ignore) name = input_line_pointer; name_end = get_symbol_end (); - ch = *name; - if (! is_name_beginner (ch)) + if (name == input_line_pointer) { as_warn (_(".end directive has no name")); *input_line_pointer = name_end; @@ -3061,11 +3059,10 @@ ecoff_directive_end (ignore) void ecoff_directive_ent (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; char name_end; - register int ch; if (cur_file_ptr == (efdr_t *) NULL) add_file ((const char *) NULL, 0, 1); @@ -3080,8 +3077,7 @@ ecoff_directive_ent (ignore) name = input_line_pointer; name_end = get_symbol_end (); - ch = *name; - if (! is_name_beginner (ch)) + if (name == input_line_pointer) { as_warn (_(".ent directive has no name")); *input_line_pointer = name_end; @@ -3103,7 +3099,7 @@ ecoff_directive_ent (ignore) ++input_line_pointer; SKIP_WHITESPACE (); } - if (isdigit ((unsigned char) *input_line_pointer) + if (ISDIGIT (*input_line_pointer) || *input_line_pointer == '-') (void) get_absolute_expression (); @@ -3114,7 +3110,7 @@ ecoff_directive_ent (ignore) void ecoff_directive_extern (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; int c; @@ -3139,7 +3135,7 @@ ecoff_directive_extern (ignore) void ecoff_directive_file (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { int indx; char *name; @@ -3147,7 +3143,7 @@ ecoff_directive_file (ignore) if (cur_proc_ptr != (proc_t *) NULL) { - as_warn (_("No way to handle .file within .ent/.end section")); + as_warn (_("no way to handle .file within .ent/.end section")); demand_empty_rest_of_line (); return; } @@ -3166,7 +3162,7 @@ ecoff_directive_file (ignore) void ecoff_directive_fmask (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { long val; @@ -3179,7 +3175,7 @@ ecoff_directive_fmask (ignore) if (get_absolute_expression_and_terminator (&val) != ',') { - as_warn (_("Bad .fmask directive")); + as_warn (_("bad .fmask directive")); --input_line_pointer; demand_empty_rest_of_line (); return; @@ -3195,7 +3191,7 @@ ecoff_directive_fmask (ignore) void ecoff_directive_frame (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { long val; @@ -3212,7 +3208,7 @@ ecoff_directive_frame (ignore) if (*input_line_pointer++ != ',' || get_absolute_expression_and_terminator (&val) != ',') { - as_warn (_("Bad .frame directive")); + as_warn (_("bad .frame directive")); --input_line_pointer; demand_empty_rest_of_line (); return; @@ -3236,7 +3232,7 @@ ecoff_directive_frame (ignore) void ecoff_directive_mask (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { long val; @@ -3249,7 +3245,7 @@ ecoff_directive_mask (ignore) if (get_absolute_expression_and_terminator (&val) != ',') { - as_warn (_("Bad .mask directive")); + as_warn (_("bad .mask directive")); --input_line_pointer; demand_empty_rest_of_line (); return; @@ -3265,7 +3261,7 @@ ecoff_directive_mask (ignore) void ecoff_directive_loc (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { lineno_list_t *list; symint_t lineno; @@ -3362,7 +3358,7 @@ ecoff_fix_loc (old_frag, old_frag_offset) static void mark_stabs (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { if (! stabs_seen) { @@ -3380,7 +3376,7 @@ mark_stabs (ignore) /* For TC_MIPS use the version in tc-mips.c. */ void ecoff_directive_weakext (ignore) - int ignore; + int ignore ATTRIBUTE_UNUSED; { char *name; int c; @@ -3398,7 +3394,7 @@ ecoff_directive_weakext (ignore) { if (S_IS_DEFINED (symbolP)) { - as_bad (_("Ignoring attempt to redefine symbol `%s'."), + as_bad (_("symbol `%s' is already defined"), S_GET_NAME (symbolP)); ignore_rest_of_line (); return; @@ -3459,7 +3455,7 @@ ecoff_directive_weakext (ignore) void ecoff_stab (sec, what, string, type, other, desc) - segT sec; + segT sec ATTRIBUTE_UNUSED; int what; const char *string; int type; @@ -3524,7 +3520,7 @@ ecoff_stab (sec, what, string, type, other, desc) dummy_symr.index = desc; if (dummy_symr.index != desc) { - as_warn (_("Line number (%d) for .stab%c directive cannot fit in index field (20 bits)"), + as_warn (_("line number (%d) for .stab%c directive cannot fit in index field (20 bits)"), desc, what); return; } @@ -3548,7 +3544,7 @@ ecoff_stab (sec, what, string, type, other, desc) listing_source_file (string); #endif - if (isdigit ((unsigned char) *input_line_pointer) + if (ISDIGIT (*input_line_pointer) || *input_line_pointer == '-' || *input_line_pointer == '+') { @@ -3560,7 +3556,7 @@ ecoff_stab (sec, what, string, type, other, desc) } else if (! is_name_beginner ((unsigned char) *input_line_pointer)) { - as_warn (_("Illegal .stab%c directive, bad character"), what); + as_warn (_("illegal .stab%c directive, bad character"), what); return; } else @@ -3643,7 +3639,7 @@ ecoff_frob_symbol (sym) if (S_IS_WEAK (sym)) { if (S_IS_COMMON (sym)) - as_bad (_("Symbol `%s' can not be both weak and common"), + as_bad (_("symbol `%s' can not be both weak and common"), S_GET_NAME (sym)); } } @@ -3689,7 +3685,7 @@ ecoff_padding_adjust (backend, buf, bufend, offset, bufptrptr) unsigned long add; add = align - (offset & (align - 1)); - if (*bufend - (*buf + offset) < add) + if ((unsigned long) (*bufend - (*buf + offset)) < add) (void) ecoff_add_bytes (buf, bufend, *buf + offset, add); memset (*buf + offset, 0, add); offset += add; @@ -4253,7 +4249,7 @@ ecoff_build_symbols (backend, buf, bufend, offset) if (local) { - if (*bufend - sym_out < external_sym_size) + if ((bfd_size_type)(*bufend - sym_out) < external_sym_size) sym_out = ecoff_add_bytes (buf, bufend, sym_out, external_sym_size); @@ -4371,7 +4367,7 @@ ecoff_build_procs (backend, buf, bufend, offset) first = 0; } proc_ptr->pdr.adr = adr - fil_ptr->fdr.adr; - if (*bufend - pdr_out < external_pdr_size) + if ((bfd_size_type)(*bufend - pdr_out) < external_pdr_size) pdr_out = ecoff_add_bytes (buf, bufend, pdr_out, external_pdr_size); @@ -4444,7 +4440,8 @@ ecoff_build_aux (backend, buf, bufend, offset) aux_end = aux_ptr + aux_cnt; for (; aux_ptr < aux_end; aux_ptr++) { - if (*bufend - (char *) aux_out < sizeof (union aux_ext)) + if ((unsigned long) (*bufend - (char *) aux_out) + < sizeof (union aux_ext)) aux_out = ((union aux_ext *) ecoff_add_bytes (buf, bufend, (char *) aux_out, @@ -4529,7 +4526,7 @@ ecoff_build_strings (buf, bufend, offset, vp) else str_cnt = vp->objects_per_page; - if (*bufend - str_out < str_cnt) + if ((unsigned long)(*bufend - str_out) < str_cnt) str_out = ecoff_add_bytes (buf, bufend, str_out, str_cnt); memcpy (str_out, str_link->datum->byte, str_cnt); @@ -4620,7 +4617,7 @@ ecoff_build_fdr (backend, buf, bufend, offset) fil_end = fil_ptr + fil_cnt; for (; fil_ptr < fil_end; fil_ptr++) { - if (*bufend - fdr_out < external_fdr_size) + if ((bfd_size_type)(*bufend - fdr_out) < external_fdr_size) fdr_out = ecoff_add_bytes (buf, bufend, fdr_out, external_fdr_size); (*swap_fdr_out) (stdoutput, &fil_ptr->fdr, fdr_out); @@ -4737,7 +4734,7 @@ ecoff_build_debug (hdr, bufp, backend) cur_file_ptr->cur_scope = cur_file_ptr->cur_scope->prev; if (! end_warning && ! cur_file_ptr->fake) { - as_warn (_("Missing .end or .bend at end of file")); + as_warn (_("missing .end or .bend at end of file")); end_warning = 1; } } @@ -4770,7 +4767,7 @@ ecoff_build_debug (hdr, bufp, backend) space at this point. */ hdr->ipdMax = proc_cnt; hdr->cbPdOffset = offset; - if (bufend - (buf + offset) < proc_cnt * external_pdr_size) + if ((bfd_size_type)(bufend - (buf + offset)) < proc_cnt * external_pdr_size) (void) ecoff_add_bytes (&buf, &bufend, buf + offset, proc_cnt * external_pdr_size); offset += proc_cnt * external_pdr_size;