Add some blank lines to improve readability.
[deliverable/binutils-gdb.git] / gas / ecoff.c
index a3080b0a9612c50eeae9b0a07c95e8d4576e49a2..682bc9efb195b41eec0035e31f25a8c78eee2533 100644 (file)
@@ -1390,6 +1390,9 @@ static const st_t map_coff_sym_type[] = {
 /* Keep track of different sized allocation requests.  */
 static alloc_info_t alloc_counts[ (int)alloc_type_last ];
 \f
+/* Record whether we have seen any debugging information.  */
+int ecoff_debugging_seen = 0;
+
 /* Various statics.  */
 static efdr_t  *cur_file_ptr   = (efdr_t *) 0; /* current file desc. header */
 static proc_t  *cur_proc_ptr   = (proc_t *) 0; /* current procedure header */
@@ -2197,11 +2200,12 @@ add_file (file_name, indx)
        as_fatal ("fake .file after real one");
       as_where (&file, (unsigned int *) NULL);
       file_name = (const char *) file;
+
       if (! symbol_table_frozen)
-       generate_asm_line_stab = 1;
+       generate_asm_lineno = 1;
     }
   else
-      generate_asm_line_stab = 0;
+      generate_asm_lineno = 0;
 
 #ifndef NO_LISTING
   if (listing)
@@ -2283,7 +2287,11 @@ add_file (file_name, indx)
       fil_ptr->int_type = add_aux_sym_tir (&int_type_info,
                                           hash_yes,
                                           &cur_file_ptr->thash_head[0]);
-      if (generate_asm_line_stab)
+      /* gas used to have a bug that if the file does not have any
+        symbol, it either will abort or will not build the file,
+        the following is to get around that problem. ---kung*/
+#if 0
+      if (generate_asm_lineno)
        {
          mark_stabs (0);
           (void) add_ecoff_symbol (file_name, st_Nil, sc_Nil,
@@ -2295,6 +2303,7 @@ add_file (file_name, indx)
                                   (symbolS *) NULL, 0,
                                   ECOFF_MARK_STAB (N_LSYM));
        }
+#endif
     }
 }
 \f
@@ -2483,6 +2492,8 @@ ecoff_directive_def (ignore)
   char *name;
   char name_end;
 
+  ecoff_debugging_seen = 1;
+
   SKIP_WHITESPACE ();
 
   name = input_line_pointer;
@@ -2669,7 +2680,11 @@ ecoff_directive_type (ignore)
     {
       if (tq_ptr == &coff_type.type_qualifiers[0])
        {
-         as_warn ("Too derived values in .type argument");
+         /* 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",
+                  coff_sym_name);
          break;
        }
       if (ISPTR (val))
@@ -3002,7 +3017,8 @@ ecoff_directive_end (ignore)
                                         (valueT) frag_now_fix (),
                                         frag_now),
                             (symint_t) 0, (symint_t) 0);
-      if (generate_asm_line_stab)
+
+      if (stabs_seen && generate_asm_lineno)
        {
        char *n;
 
@@ -3321,7 +3337,8 @@ mark_stabs (ignore)
        value           a numeric value or an address.  */
 
 void
-ecoff_stab (what, string, type, other, desc)
+ecoff_stab (sec, what, string, type, other, desc)
+     segT sec;
      int what;
      const char *string;
      int type;
@@ -3336,6 +3353,8 @@ ecoff_stab (what, string, type, other, desc)
   symint_t indx;
   localsym_t *hold = NULL;
 
+  ecoff_debugging_seen = 1;
+
   /* We don't handle .stabd.  */
   if (what != 's' && what != 'n')
     {
@@ -3897,7 +3916,12 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                          if (! ECOFF_IS_STAB (&sym_ptr->ecoff_sym.asym)
                              && (S_IS_EXTERNAL (as_sym)
                                  || ! S_IS_DEFINED (as_sym)))
-                           st = st_Global;
+                           {
+                             if ((as_sym->bsym->flags & BSF_FUNCTION) != 0)
+                               st = st_Proc;
+                             else
+                               st = st_Global;
+                           }
                          else if (seg == text_section)
                            st = st_Label;
                          else
@@ -3941,7 +3965,12 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                          else if (seg == &bfd_abs_section)
                            sc = sc_Abs;
                          else
-                           abort ();
+                           {
+                             /* This must be a user named section.
+                                 This is not possible in ECOFF, but it
+                                 is in ELF.  */
+                             sc = sc_Data;
+                           }
 
                          sym_ptr->ecoff_sym.asym.st = (int) st;
                          sym_ptr->ecoff_sym.asym.sc = (int) sc;
@@ -4077,12 +4106,10 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                  if (as_sym != (symbolS *) NULL
                      && as_sym->ecoff_symbol == sym_ptr)
                    {
-                     if (sym_ptr->ecoff_sym.asym.st == st_Proc
-                         || sym_ptr->ecoff_sym.asym.st == st_StaticProc)
-                       {
-                         know (local);
-                         sym_ptr->ecoff_sym.asym.index = isym - ifilesym - 1;
-                       }
+                     if ((sym_ptr->ecoff_sym.asym.st == st_Proc
+                          || sym_ptr->ecoff_sym.asym.st == st_StaticProc)
+                         && local)
+                       sym_ptr->ecoff_sym.asym.index = isym - ifilesym - 1;
                      sym_ptr->ecoff_sym.ifd = fil_ptr->file_index;
                    }
                }
@@ -4525,7 +4552,8 @@ ecoff_build_debug (hdr, bufp, backend)
        fil_ptr = fil_ptr->next_file)
     {
       cur_file_ptr = fil_ptr;
-      while (cur_file_ptr->cur_scope->prev != (scope_t *) NULL)
+      while (cur_file_ptr->cur_scope != (scope_t *) NULL
+            && cur_file_ptr->cur_scope->prev != (scope_t *) NULL)
        {
          cur_file_ptr->cur_scope = cur_file_ptr->cur_scope->prev;
          if (! end_warning)
@@ -4534,11 +4562,12 @@ ecoff_build_debug (hdr, bufp, backend)
              end_warning = 1;
            }
        }
-      (void) add_ecoff_symbol ((const char *) NULL,
-                              st_End, sc_Text,
-                              (symbolS *) NULL,
-                              (symint_t) 0,
-                              (symint_t) 0);
+      if (cur_file_ptr->cur_scope != (scope_t *) NULL)
+       (void) add_ecoff_symbol ((const char *) NULL,
+                                st_End, sc_Text,
+                                (symbolS *) NULL,
+                                (symint_t) 0,
+                                (symint_t) 0);
     }
 
   /* Build the symbolic information.  */
@@ -5014,7 +5043,7 @@ ecoff_set_gp_prolog_size (sz)
      int sz;
 {
   if (cur_proc_ptr == 0)
-    abort ();
+    return;
 
   cur_proc_ptr->pdr.gp_prologue = sz;
   if (cur_proc_ptr->pdr.gp_prologue != sz)
@@ -5123,6 +5152,60 @@ generate_ecoff_stab (what, string, type, other, desc)
   cur_file_ptr = save_file_ptr;
 }
 
+int 
+ecoff_no_current_file ()
+{
+  return cur_file_ptr == (efdr_t *) NULL;
+}
+
+void
+ecoff_generate_asm_lineno (filename, lineno)
+     const char *filename;
+     int lineno;
+{
+  lineno_list_t *list;
+
+  /* this potential can cause problem, when we start to see stab half the 
+     way thru the file */
+/*
+  if (stabs_seen)
+    ecoff_generate_asm_line_stab(filename, lineno);
+*/
+
+  if (current_stabs_filename == (char *)NULL || strcmp (current_stabs_filename, filename))
+    {
+      add_file (filename, 0);
+      generate_asm_lineno = 1;
+    }
+
+  list = allocate_lineno_list ();
+
+  list->next = (lineno_list_t *) NULL;
+  list->file = cur_file_ptr;
+  list->proc = cur_proc_ptr;
+  list->frag = frag_now;
+  list->paddr = frag_now_fix ();
+  list->lineno = lineno;
+
+  /* A .loc directive will sometimes appear before a .ent directive,
+     which means that cur_proc_ptr will be NULL here.  Arrange to
+     patch this up.  */
+  if (cur_proc_ptr == (proc_t *) NULL)
+    {
+      lineno_list_t **pl;
+
+      pl = &noproc_lineno;
+      while (*pl != (lineno_list_t *) NULL)
+        pl = &(*pl)->next;
+      *pl = list;
+    }
+  else
+    {
+      *last_lineno_ptr = list;
+      last_lineno_ptr = &list->next;
+    }
+}
+
 static int line_label_cnt = 0;
 void
 ecoff_generate_asm_line_stab (filename, lineno)
@@ -5134,7 +5217,7 @@ ecoff_generate_asm_line_stab (filename, lineno)
   if (strcmp (current_stabs_filename, filename)) 
     {
       add_file (filename, 0);
-      generate_asm_line_stab = 1;
+      generate_asm_lineno = 1;
     }
 
   line_label_cnt++;
This page took 0.026195 seconds and 4 git commands to generate.