The patch contains mostly fixes for the disassembler. It also fixes
[deliverable/binutils-gdb.git] / gas / ecoff.c
index f04e530e1a8fb5f407051c52108bcba04508086e..ed1192115ff97452dd444e4bf0d6227ba15daa45 100644 (file)
@@ -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
+   Free Software Foundation, Inc.
    Contributed by Cygnus Support.
    This file was put together by Ian Lance Taylor <ian@cygnus.com>.  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 <ctype.h>
+#include "safe-ctype.h"
 
 /* Why isn't this in coff/sym.h?  */
 #define ST_RFDESCAPE 0xfff
@@ -1552,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)
@@ -1578,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);
     }
 
@@ -2041,7 +2042,7 @@ get_tag (tag, sym, basic_type)
       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;
     }
@@ -2189,7 +2190,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;
@@ -2219,7 +2220,7 @@ add_file (file_name, indx, fake)
       if (! symbol_table_frozen && debug_type == DEBUG_UNSPECIFIED)
        debug_type = DEBUG_ECOFF;
     }
-  else
+  else if (debug_type == DEBUG_UNSPECIFIED)
     debug_type = DEBUG_NONE;
 
 #ifndef NO_LISTING
@@ -2297,7 +2298,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.  */
@@ -2425,7 +2426,7 @@ st_to_string (symbol_type)
 
 void
 ecoff_directive_begin (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *name;
   char name_end;
@@ -2463,7 +2464,7 @@ ecoff_directive_begin (ignore)
 
 void
 ecoff_directive_bend (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *name;
   char name_end;
@@ -2522,7 +2523,7 @@ static int coff_inside_enumeration;
 
 void
 ecoff_directive_def (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *name;
   char name_end;
@@ -2537,7 +2538,7 @@ 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)
@@ -2568,7 +2569,7 @@ ecoff_directive_def (ignore)
 
 void
 ecoff_directive_dim (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   int dimens[N_TQ];
   int i;
@@ -2590,7 +2591,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;
        }
     }
@@ -2603,7 +2604,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];
@@ -2618,7 +2619,7 @@ ecoff_directive_dim (ignore)
 
 void
 ecoff_directive_scl (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   long val;
 
@@ -2643,7 +2644,7 @@ ecoff_directive_scl (ignore)
 
 void
 ecoff_directive_size (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   int sizes[N_TQ];
   int i;
@@ -2665,7 +2666,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;
        }
     }
@@ -2678,7 +2679,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];
@@ -2693,7 +2694,7 @@ ecoff_directive_size (ignore)
 
 void
 ecoff_directive_type (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   long val;
   tq_t *tq_ptr;
@@ -2719,7 +2720,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;
        }
@@ -2762,7 +2763,7 @@ ecoff_directive_type (ignore)
 
 void
 ecoff_directive_tag (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *name;
   char name_end;
@@ -2790,7 +2791,7 @@ ecoff_directive_tag (ignore)
 
 void
 ecoff_directive_val (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   expressionS exp;
 
@@ -2825,7 +2826,7 @@ ecoff_directive_val (ignore)
 
 void
 ecoff_directive_endef (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *name;
   symint_t indx;
@@ -2861,7 +2862,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;
        }
 
@@ -2910,7 +2911,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;
            }
 
@@ -2942,7 +2943,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
@@ -3005,11 +3006,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)
@@ -3029,8 +3029,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;
@@ -3062,11 +3061,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);
@@ -3081,8 +3079,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;
@@ -3104,7 +3101,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 ();
 
@@ -3115,7 +3112,7 @@ ecoff_directive_ent (ignore)
 
 void
 ecoff_directive_extern (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   char *name;
   int c;
@@ -3140,7 +3137,7 @@ ecoff_directive_extern (ignore)
 
 void
 ecoff_directive_file (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   int indx;
   char *name;
@@ -3148,7 +3145,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;
     }
@@ -3167,7 +3164,7 @@ ecoff_directive_file (ignore)
 
 void
 ecoff_directive_fmask (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   long val;
 
@@ -3180,7 +3177,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;
@@ -3196,7 +3193,7 @@ ecoff_directive_fmask (ignore)
 
 void
 ecoff_directive_frame (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   long val;
 
@@ -3213,7 +3210,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;
@@ -3237,7 +3234,7 @@ ecoff_directive_frame (ignore)
 
 void
 ecoff_directive_mask (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   long val;
 
@@ -3250,7 +3247,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;
@@ -3266,7 +3263,7 @@ ecoff_directive_mask (ignore)
 
 void
 ecoff_directive_loc (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   lineno_list_t *list;
   symint_t lineno;
@@ -3363,7 +3360,7 @@ ecoff_fix_loc (old_frag, old_frag_offset)
 
 static void
 mark_stabs (ignore)
-     int ignore;
+     int ignore ATTRIBUTE_UNUSED;
 {
   if (! stabs_seen)
     {
@@ -3399,7 +3396,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;
@@ -3460,7 +3457,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;
@@ -3525,7 +3522,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;
        }
@@ -3549,7 +3546,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 == '+')
        {
@@ -3561,7 +3558,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
@@ -3644,7 +3641,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));
     }
 }
@@ -3690,7 +3687,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;
@@ -4254,7 +4251,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);
@@ -4372,7 +4369,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);
@@ -4445,7 +4442,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,
@@ -4530,7 +4528,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);
@@ -4621,7 +4619,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);
@@ -4738,7 +4736,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;
            }
        }
@@ -4771,7 +4769,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;
This page took 0.030594 seconds and 4 git commands to generate.