Fixed node name.
[deliverable/binutils-gdb.git] / gas / ecoff.c
index 51d5c659317442e7121dd73ef851e3c8c7556cdb..082192230373e78a43057751a893a8130442e1ce 100644 (file)
@@ -1,5 +1,5 @@
 /* ECOFF debugging support.
-   Copyright (C) 1993 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1996 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
@@ -18,8 +18,9 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with GAS; see the file COPYING.  If not, write to
-   the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   along with GAS; see the file COPYING.  If not, write to the Free
+   Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.  */
 
 #include "as.h"
 
@@ -832,6 +833,7 @@ typedef struct scope {
 typedef struct localsym {
   const char *name;            /* symbol name */
   symbolS *as_sym;             /* symbol as seen by gas */
+  bfd_vma addend;              /* addend to as_sym value */
   struct efdr *file_ptr;       /* file pointer */
   struct ecoff_proc *proc_ptr; /* proc pointer */
   struct localsym *begin_ptr;  /* symbol at start of block */
@@ -973,13 +975,9 @@ static const efdr_t init_file =
     0,                 /* rfdBase:     index into the file indirect table */
     0,                 /* crfd:        count file indirect entries */
     langC,             /* lang:        language for this file */
-    0,                 /* fMerge:      whether this file can be merged */
+    1,                 /* fMerge:      whether this file can be merged */
     0,                 /* fReadin:     true if read in (not just created) */
-#ifdef TARGET_BYTES_BIG_ENDIAN
-    1,                 /* fBigendian:  if 1, compiled on big endian machine */
-#else
-    0,                 /* fBigendian:  if 1, compiled on big endian machine */
-#endif
+    TARGET_BYTES_BIG_ENDIAN,  /* fBigendian:   if 1, compiled on big endian machine */
     GLEVEL_2,          /* glevel:      level this file was compiled with */
     0,                 /* reserved:    reserved for future use */
     0,                 /* cbLineOffset: byte offset from header for this file ln's */
@@ -1022,6 +1020,7 @@ typedef struct lineno_list {
 } lineno_list_t;
 
 static lineno_list_t *first_lineno;
+static lineno_list_t *last_lineno;
 static lineno_list_t **last_lineno_ptr = &first_lineno;
 
 /* Sometimes there will be some .loc statements before a .ent.  We
@@ -1047,13 +1046,13 @@ typedef union page {
   forward_t    forward [ PAGE_SIZE / sizeof (forward_t)     ];
   thead_t      thead   [ PAGE_SIZE / sizeof (thead_t)       ];
   lineno_list_t        lineno  [ PAGE_SIZE / sizeof (lineno_list_t) ];
-} page_t;
+} page_type;
 
 
 /* Structure holding allocation information for small sized structures.  */
 typedef struct alloc_info {
   char         *alloc_name;    /* name of this allocation type (must be first) */
-  page_t       *cur_page;      /* current page being allocated from */
+  page_type    *cur_page;      /* current page being allocated from */
   small_free_t  free_list;     /* current free list if any */
   int           unallocated;   /* number of elements unallocated on page */
   int           total_alloc;   /* total number of allocations */
@@ -1425,7 +1424,7 @@ static symint_t add_string PARAMS ((varray_t *vp,
                                    shash_t **ret_hash));
 static localsym_t *add_ecoff_symbol PARAMS ((const char *str, st_t type,
                                             sc_t storage, symbolS *sym,
-                                            symint_t value,
+                                            bfd_vma addend, symint_t value,
                                             symint_t indx));
 static symint_t add_aux_sym_symint PARAMS ((symint_t aux_word));
 static symint_t add_aux_sym_rndx PARAMS ((int file_index,
@@ -1470,8 +1469,8 @@ static unsigned long ecoff_build_fdr
   PARAMS ((const struct ecoff_debug_swap *backend, char **buf, char **bufend,
           unsigned long offset));
 static void ecoff_setup_ext PARAMS ((void));
-static page_t *allocate_cluster PARAMS ((unsigned long npages));
-static page_t *allocate_page PARAMS ((void));
+static page_type *allocate_cluster PARAMS ((unsigned long npages));
+static page_type *allocate_page PARAMS ((void));
 static scope_t *allocate_scope PARAMS ((void));
 static void free_scope PARAMS ((scope_t *ptr));
 static vlinks_t *allocate_vlinks PARAMS ((void));
@@ -1527,7 +1526,7 @@ add_varray_page (vp)
 
 #ifdef MALLOC_CHECK
   if (vp->object_size > 1)
-    new_links->datum = (page_t *) xcalloc (1, vp->object_size);
+    new_links->datum = (page_type *) xcalloc (1, vp->object_size);
   else
 #endif
     new_links->datum = allocate_page ();
@@ -1600,11 +1599,12 @@ add_string (vp, hash_tbl, str, ret_hash)
 /* Add debugging information for a symbol.  */
 
 static localsym_t *
-add_ecoff_symbol (str, type, storage, sym_value, value, indx)
+add_ecoff_symbol (str, type, storage, sym_value, addend, value, indx)
      const char *str;                  /* symbol name */
      st_t type;                                /* symbol type */
      sc_t storage;                     /* storage class */
      symbolS *sym_value;               /* associated symbol.  */
+     bfd_vma addend;                   /* addend to sym_value.  */
      symint_t value;                   /* value of symbol */
      symint_t indx;                    /* index to local/aux. syms */
 {
@@ -1634,6 +1634,7 @@ add_ecoff_symbol (str, type, storage, sym_value, value, indx)
   psym->as_sym = sym_value;
   if (sym_value != (symbolS *) NULL)
     sym_value->ecoff_symbol = psym;
+  psym->addend = addend;
   psym->file_ptr = cur_file_ptr;
   psym->proc_ptr = cur_proc_ptr;
   psym->begin_ptr = (localsym_t *) NULL;
@@ -2104,6 +2105,7 @@ add_unknown_tag (ptag)
                          st_Block,
                          sc_Info,
                          (symbolS *) NULL,
+                         (bfd_vma) 0,
                          (symint_t) 0,
                          (symint_t) 0);
 
@@ -2111,6 +2113,7 @@ add_unknown_tag (ptag)
                           st_End,
                           sc_Info,
                           (symbolS *) NULL,
+                          (bfd_vma) 0,
                           (symint_t) 0,
                           (symint_t) 0);
 
@@ -2128,6 +2131,7 @@ add_procedure (func)
 {
   register varray_t *vp;
   register proc_t *new_proc_ptr;
+  symbolS *sym;
 
 #ifdef ECOFF_DEBUG
   if (debug)
@@ -2154,10 +2158,14 @@ add_procedure (func)
   new_proc_ptr->pdr.lnLow = -1;
   new_proc_ptr->pdr.lnHigh = -1;
 
+  /* Set the BSF_FUNCTION flag for the symbol.  */
+  sym = symbol_find_or_make (func);
+  sym->bsym->flags |= BSF_FUNCTION;
+
   /* Push the start of the function.  */
   new_proc_ptr->sym = add_ecoff_symbol ((const char *) NULL, st_Proc, sc_Text,
-                                       symbol_find_or_make (func),
-                                       (symint_t) 0, (symint_t) 0);
+                                       sym, (bfd_vma) 0, (symint_t) 0,
+                                       (symint_t) 0);
 
   ++proc_cnt;
 
@@ -2170,7 +2178,10 @@ add_procedure (func)
        l->proc = new_proc_ptr;
       *last_lineno_ptr = noproc_lineno;
       while (*last_lineno_ptr != NULL)
-       last_lineno_ptr = &(*last_lineno_ptr)->next;
+       {
+         last_lineno = *last_lineno_ptr;
+         last_lineno_ptr = &last_lineno->next;
+       }
       noproc_lineno = (lineno_list_t *) NULL;
     }
 }
@@ -2204,11 +2215,14 @@ add_file (file_name, indx, fake)
       as_where (&file, (unsigned int *) NULL);
       file_name = (const char *) file;
 
-      if (! symbol_table_frozen)
-       generate_asm_lineno = 1;
+      /* Automatically generate ECOFF debugging information, since I
+         think that's what other ECOFF assemblers do.  We don't do
+         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)
+       debug_type = DEBUG_ECOFF;
     }
-  else
-      generate_asm_lineno = 0;
 
 #ifndef NO_LISTING
   if (listing)
@@ -2225,32 +2239,33 @@ add_file (file_name, indx, fake)
                               symbol_new ("L0\001", now_seg,
                                           (valueT) frag_now_fix (),
                                           frag_now),
-                              0, ECOFF_MARK_STAB (N_SOL));
+                              (bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SOL));
       return;
     }
 
   first_ch = *file_name;
 
-  /* ??? This is ifdefed out, because it results in incorrect line number
-     debugging info when multiple .file pseudo-ops are merged into one file
-     descriptor.  See for instance ecoff_build_lineno, which will
-     end up setting all file->fdr.* fields multiple times, resulting in
-     incorrect debug info.  In order to make this work right, all line number
-     and symbol info for the same source file has to be adjacent in the object
-     file, so that a single file descriptor can be used to point to them.
-     This would require maintaining file specific lists of line numbers and
-     symbols for each file, so that they can be merged together (or output
-     together) when two .file pseudo-ops are merged into one file
-     descriptor.  */
-
-#if 0
+  /* FIXME: We can't safely merge files which have line number
+     information (fMerge will be zero in this case).  Otherwise, we
+     get incorrect line number debugging info.  See for instance
+     ecoff_build_lineno, which will end up setting all file->fdr.*
+     fields multiple times, resulting in incorrect debug info.  In
+     order to make this work right, all line number and symbol info
+     for the same source file has to be adjacent in the object file,
+     so that a single file descriptor can be used to point to them.
+     This would require maintaining file specific lists of line
+     numbers and symbols for each file, so that they can be merged
+     together (or output together) when two .file pseudo-ops are
+     merged into one file descriptor.  */
+
   /* See if the file has already been created.  */
   for (fil_ptr = first_file;
        fil_ptr != (efdr_t *) NULL;
        fil_ptr = fil_ptr->next_file)
     {
       if (first_ch == fil_ptr->name[0]
-         && strcmp (file_name, fil_ptr->name) == 0)
+         && strcmp (file_name, fil_ptr->name) == 0
+         && fil_ptr->fdr.fMerge)
        {
          cur_file_ptr = fil_ptr;
          if (! fake)
@@ -2258,9 +2273,6 @@ add_file (file_name, indx, fake)
          break;
        }
     }
-#else
-  fil_ptr = (efdr_t *) NULL;
-#endif
 
   /* If this is a new file, create it. */
   if (fil_ptr == (efdr_t *) NULL)
@@ -2292,7 +2304,7 @@ add_file (file_name, indx, fake)
       /* Push the start of the filename. We assume that the filename
          will be stored at string offset 1.  */
       (void) add_ecoff_symbol (file_name, st_File, sc_Text,
-                              (symbolS *) NULL,
+                              (symbolS *) NULL, (bfd_vma) 0,
                               (symint_t) 0, (symint_t) 0);
       fil_ptr->fdr.rss = 1;
       fil_ptr->name = &fil_ptr->strings.last->datum->byte[1];
@@ -2310,25 +2322,26 @@ add_file (file_name, indx, fake)
       fil_ptr->int_type = add_aux_sym_tir (&int_type_info,
                                           hash_yes,
                                           &cur_file_ptr->thash_head[0]);
-      /* 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,
-                                  symbol_new ("L0\001", now_seg,
-                                              (valueT) frag_now_fix (),
-                                              frag_now),
-                                  0, ECOFF_MARK_STAB (N_SO));
-          (void) add_ecoff_symbol ("void:t1=1", st_Nil, sc_Nil,
-                                  (symbolS *) NULL, 0,
-                                  ECOFF_MARK_STAB (N_LSYM));
-       }
-#endif
     }
 }
+
+/* This function is called when the assembler notices a preprocessor
+   directive switching to a new file.  This will not happen in
+   compiler output, only in hand coded assembler.  */
+
+void
+ecoff_new_file (name)
+     const char *name;
+{
+  if (cur_file_ptr != NULL && strcmp (cur_file_ptr->name, name) == 0)
+    return;
+  add_file (name, 0, 0);
+
+  /* This is a hand coded assembler file, so automatically turn on
+     debugging information.  */
+  if (debug_type == DEBUG_NONE)
+    debug_type = DEBUG_ECOFF;
+}
 \f
 #ifdef ECOFF_DEBUG
 
@@ -2438,7 +2451,7 @@ ecoff_directive_begin (ignore)
 
   (void) add_ecoff_symbol ((const char *) NULL, st_Block, sc_Text,
                           symbol_find_or_make (name),
-                          (symint_t) 0, (symint_t) 0);
+                          (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
 
   *input_line_pointer = name_end;
 
@@ -2483,7 +2496,7 @@ ecoff_directive_bend (ignore)
     as_warn (".bend directive names unknown symbol");
   else
     (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text, endsym,
-                            (symint_t) 0, (symint_t) 0);
+                            (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
 
   *input_line_pointer = name_end;
 
@@ -2503,7 +2516,8 @@ static st_t coff_symbol_typ;
 static int coff_is_function;
 static char *coff_tag;
 static valueT coff_value;
-symbolS *coff_sym_value;
+static symbolS *coff_sym_value;
+static bfd_vma coff_sym_addend;
 static int coff_inside_enumeration;
 
 /* Handle a .def directive: start defining a symbol.  */
@@ -2541,6 +2555,7 @@ ecoff_directive_def (ignore)
       coff_tag = (char *) NULL;
       coff_value = 0;
       coff_sym_value = (symbolS *) NULL;
+      coff_sym_addend = 0;
     }
 
   *input_line_pointer = name_end;
@@ -2779,6 +2794,8 @@ void
 ecoff_directive_val (ignore)
      int ignore;
 {
+  expressionS exp;
+
   if (coff_sym_name == (char *) NULL)
     {
       as_warn (".val pseudo-op used outside of .def/.endef; ignored");
@@ -2786,26 +2803,20 @@ ecoff_directive_val (ignore)
       return;
     }
 
-  if (! is_name_beginner ((unsigned char) *input_line_pointer))
-    coff_value = get_absolute_expression ();
-  else
+  expression (&exp);
+  if (exp.X_op != O_constant && exp.X_op != O_symbol)
     {
-      char *name;
-      char name_end;
-
-      name = input_line_pointer;
-      name_end = get_symbol_end ();
-
-      if (strcmp (name, ".") == 0)
-       as_warn ("`.val .' not supported");
-      else
-       coff_sym_value = symbol_find_or_make (name);
-
-      *input_line_pointer = name_end;
+      as_bad (".val expression is too copmlex");
+      demand_empty_rest_of_line ();
+      return;
+    }
 
-      /* FIXME: gcc can generate address expressions here in unusual
-        cases (search for "obscure" in sdbout.c), although this is
-        very unlikely for a MIPS chip.  */
+  if (exp.X_op == O_constant)
+    coff_value = exp.X_add_number;
+  else
+    {
+      coff_sym_value = exp.X_add_symbol;
+      coff_sym_addend = exp.X_add_number;
     }
 
   demand_empty_rest_of_line ();
@@ -2873,8 +2884,10 @@ ecoff_directive_endef (ignore)
 
          coff_type.num_sizes = i + 1;
          for (i--; i >= 0; i--)
-           coff_type.sizes[i] = (coff_type.sizes[i + 1]
-                                 / coff_type.dimensions[i + 1]);
+           coff_type.sizes[i] = (coff_type.dimensions[i + 1] == 0
+                                 ? 0
+                                 : (coff_type.sizes[i + 1]
+                                    / coff_type.dimensions[i + 1]));
        }
     }
   else if (coff_symbol_typ == st_Member
@@ -2967,6 +2980,7 @@ ecoff_directive_endef (ignore)
                          coff_symbol_typ,
                          coff_storage_class,
                          coff_sym_value,
+                         coff_sym_addend,
                          (symint_t) coff_value,
                          indx);
 
@@ -3034,24 +3048,11 @@ ecoff_directive_end (ignore)
   if (ent == (symbolS *) NULL)
     as_warn (".end directive names unknown symbol");
   else
-    {
-      (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
+    (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
                             symbol_new ("L0\001", now_seg,
                                         (valueT) frag_now_fix (),
                                         frag_now),
-                            (symint_t) 0, (symint_t) 0);
-
-      if (stabs_seen && generate_asm_lineno)
-       {
-       char *n;
-
-         n = xmalloc (strlen (name) + 4);
-         strcpy (n, name);
-         strcat (n, ":F1");
-         (void) add_ecoff_symbol ((const char *) n, stGlobal, scText, 
-                               ent, 0, ECOFF_MARK_STAB (N_FUN));
-       }
-    }
+                            (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
 
   cur_proc_ptr = (proc_t *) NULL;
 
@@ -3304,7 +3305,7 @@ ecoff_directive_loc (ignore)
                               symbol_new ("L0\001", now_seg,
                                           (valueT) frag_now_fix (),
                                           frag_now),
-                              0, lineno);
+                              (bfd_vma) 0, 0, lineno);
       return;
     }
 
@@ -3317,6 +3318,9 @@ ecoff_directive_loc (ignore)
   list->paddr = frag_now_fix ();
   list->lineno = lineno;
 
+  /* We don't want to merge files which have line numbers.  */
+  cur_file_ptr->fdr.fMerge = 0;
+
   /* 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.  */
@@ -3331,10 +3335,29 @@ ecoff_directive_loc (ignore)
     }
   else
     {
+      last_lineno = list;
       *last_lineno_ptr = list;
       last_lineno_ptr = &list->next;
     }
 }
+
+/* The MIPS assembler sometimes inserts nop instructions in the
+   instruction stream.  When this happens, we must patch up the .loc
+   information so that it points to the instruction after the nop.  */
+
+void
+ecoff_fix_loc (old_frag, old_frag_offset)
+     fragS *old_frag;
+     unsigned long old_frag_offset;
+{
+  if (last_lineno != NULL
+      && last_lineno->frag == old_frag
+      && last_lineno->paddr == old_frag_offset)
+    {
+      last_lineno->frag = frag_now;
+      last_lineno->paddr = frag_now_fix ();
+    }
+}
 \f
 /* Make sure the @stabs symbol is emitted.  */
 
@@ -3348,7 +3371,8 @@ mark_stabs (ignore)
       stabs_seen = 1;
       (void) add_ecoff_symbol (stabs_symbol, stNil, scInfo,
                               (symbolS *) NULL,
-                              (symint_t) -1, ECOFF_MARK_STAB (0));
+                              (bfd_vma) 0, (symint_t) -1,
+                              ECOFF_MARK_STAB (0));
     }
 }
 \f
@@ -3370,7 +3394,7 @@ ecoff_directive_weakext (ignore)
 
   SKIP_WHITESPACE ();
 
-  if (c == ',')
+  if (*input_line_pointer == ',')
     {
       if (S_IS_DEFINED (symbolP))
        {
@@ -3444,6 +3468,7 @@ ecoff_stab (sec, what, string, type, other, desc)
   efdr_t *save_file_ptr = cur_file_ptr;
   symbolS *sym;
   symint_t value;
+  bfd_vma addend;
   st_t st;
   sc_t sc;
   symint_t indx;
@@ -3510,6 +3535,7 @@ ecoff_stab (sec, what, string, type, other, desc)
       *input_line_pointer = name_end;
 
       value = 0;
+      addend = 0;
       st = st_Label;
       sc = sc_Text;
       indx = desc;
@@ -3529,6 +3555,7 @@ ecoff_stab (sec, what, string, type, other, desc)
          sc = sc_Nil;
          sym = (symbolS *) NULL;
          value = get_absolute_expression ();
+         addend = 0;
        }
       else if (! is_name_beginner ((unsigned char) *input_line_pointer))
        {
@@ -3537,25 +3564,29 @@ ecoff_stab (sec, what, string, type, other, desc)
        }
       else
        {
-         char *name;
-         char name_end;
-
-         name = input_line_pointer;
-         name_end = get_symbol_end ();
-
-         sym = symbol_find_or_make (name);
+         expressionS exp;
 
          sc = sc_Nil;
          st = st_Nil;
-         value = 0;
 
-         *input_line_pointer = name_end;
-         if (name_end == '+' || name_end == '-')
+         expression (&exp);
+         if (exp.X_op == O_constant)
            {
-             ++input_line_pointer;
-             value = get_absolute_expression ();
-             if (name_end == '-')
-               value = - value;
+             sym = NULL;
+             value = exp.X_add_number;
+             addend = 0;
+           }
+         else if (exp.X_op == O_symbol)
+           {
+             sym = exp.X_add_symbol;
+             value = 0;
+             addend = exp.X_add_number;
+           }
+         else
+           {
+             sym = make_expr_symbol (&exp);
+             value = 0;
+             addend = 0;
            }
        }
 
@@ -3568,7 +3599,7 @@ ecoff_stab (sec, what, string, type, other, desc)
   if (sym != (symbolS *) NULL)
     hold = sym->ecoff_symbol;
 
-  (void) add_ecoff_symbol (string, st, sc, sym, value, indx);
+  (void) add_ecoff_symbol (string, st, sc, sym, addend, value, indx);
 
   if (sym != (symbolS *) NULL)
     sym->ecoff_symbol = hold;
@@ -3585,8 +3616,8 @@ ecoff_frob_symbol (sym)
      symbolS *sym;
 {
   if (S_IS_COMMON (sym)
-          && S_GET_VALUE (sym) > 0
-          && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
+      && S_GET_VALUE (sym) > 0
+      && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
     {
       static asection scom_section;
       static asymbol scom_symbol;
@@ -3606,6 +3637,14 @@ ecoff_frob_symbol (sym)
        }
       S_SET_SEGMENT (sym, &scom_section);
     }
+
+  /* Double check weak symbols.  */
+  if (sym->bsym->flags & BSF_WEAK)
+    {
+      if (S_IS_COMMON (sym))
+       as_bad ("Symbol `%s' can not be both weak and common",
+               S_GET_NAME (sym));
+    }
 }
 \f
 /* Add bytes to the symbolic information buffer.  */
@@ -3730,16 +3769,17 @@ ecoff_build_lineno (backend, buf, bufend, offset, linecntptr)
             before it is used.  */
          count = 1;
        }
-      else
+      else if (l->next->frag->fr_address + l->next->paddr
+              > l->frag->fr_address + l->paddr)
        {
          count = ((l->next->frag->fr_address + l->next->paddr
                    - (l->frag->fr_address + l->paddr))
                   >> 2);
-         if (count <= 0)
-           {
-             /* Don't change last, so we still get the right delta.  */
-             continue;
-           }
+       }
+      else
+       {
+         /* Don't change last, so we still get the right delta.  */
+         continue;
        }
 
       if (l->file != file || l->proc != proc)
@@ -3984,7 +4024,8 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                        sym_ptr->ecoff_sym.asym.value =
                          (S_GET_VALUE (as_sym)
                           + bfd_get_section_vma (stdoutput,
-                                                 S_GET_SEGMENT (as_sym)));
+                                                 S_GET_SEGMENT (as_sym))
+                          + sym_ptr->addend);
 
                      sym_ptr->ecoff_sym.weakext = S_IS_WEAK (as_sym);
 
@@ -4041,6 +4082,9 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                                  sym_ptr->ecoff_sym.asym.value =
                                    as_sym->ecoff_extern_size;
                                }
+#ifdef S_SET_SIZE
+                             S_SET_SIZE (as_sym, as_sym->ecoff_extern_size);
+#endif
                            }
                          else if (S_IS_COMMON (as_sym))
                            {
@@ -4092,6 +4136,11 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                          && ! ECOFF_IS_STAB (&sym_ptr->ecoff_sym.asym))
                        local = 0;
 
+                     /* This is just an external symbol if it is a
+                         common symbol.  */
+                     if (S_IS_COMMON (as_sym))
+                       local = 0;
+
                      /* If an st_end symbol has an associated gas
                         symbol, then it is a local label created for
                         a .bend or .end directive.  Stabs line
@@ -4158,6 +4207,16 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                          sym_ptr->ecoff_sym.asym.value =
                            (S_GET_VALUE (as_sym)
                             - S_GET_VALUE (begin_ptr->as_sym));
+
+                         /* If the size is odd, this is probably a
+                             mips16 function; force it to be even.  */
+                         if ((sym_ptr->ecoff_sym.asym.value & 1) != 0)
+                           ++sym_ptr->ecoff_sym.asym.value;
+
+#ifdef S_SET_SIZE
+                         S_SET_SIZE (begin_ptr->as_sym,
+                                     sym_ptr->ecoff_sym.asym.value);
+#endif
                        }
                      else if (begin_type == st_Block
                               && sym_ptr->ecoff_sym.asym.sc != (int) sc_Info)
@@ -4214,6 +4273,11 @@ ecoff_build_symbols (backend, buf, bufend, offset)
                          && local)
                        sym_ptr->ecoff_sym.asym.index = isym - ifilesym - 1;
                      sym_ptr->ecoff_sym.ifd = fil_ptr->file_index;
+
+                     /* Don't try to merge an FDR which has an
+                         external symbol attached to it.  */
+                     if (S_IS_EXTERNAL (as_sym) || S_IS_WEAK (as_sym))
+                       fil_ptr->fdr.fMerge = 0;
                    }
                }
            }
@@ -4329,7 +4393,7 @@ ecoff_build_aux (backend, buf, bufend, offset)
   long iaux;
   vlinks_t *file_link;
 
-  bigendian = stdoutput->xvec->header_byteorder_big_p;
+  bigendian = bfd_big_endian (stdoutput);
 
   aux_out = (union aux_ext *) (*buf + offset);
 
@@ -4642,7 +4706,7 @@ ecoff_build_debug (hdr, bufp, backend)
 
       cur_file_ptr = sym->ecoff_file;
       add_ecoff_symbol ((const char *) NULL, st_Nil, sc_Nil, sym,
-                       S_GET_VALUE (sym), indexNil);
+                       (bfd_vma) 0, S_GET_VALUE (sym), indexNil);
     }
   cur_proc_ptr = hold_proc_ptr;
   cur_file_ptr = hold_file_ptr;
@@ -4670,6 +4734,7 @@ ecoff_build_debug (hdr, bufp, backend)
        (void) add_ecoff_symbol ((const char *) NULL,
                                 st_End, sc_Text,
                                 (symbolS *) NULL,
+                                (bfd_vma) 0,
                                 (symint_t) 0,
                                 (symint_t) 0);
     }
@@ -4757,11 +4822,11 @@ ecoff_build_debug (hdr, bufp, backend)
 
 #ifndef MALLOC_CHECK
 
-static page_t *
+static page_type *
 allocate_cluster (npages)
      unsigned long npages;
 {
-  register page_t *value = (page_t *) xmalloc (npages * PAGE_USIZE);
+  register page_type *value = (page_type *) xmalloc (npages * PAGE_USIZE);
 
 #ifdef ECOFF_DEBUG
   if (debug > 3)
@@ -4774,14 +4839,14 @@ allocate_cluster (npages)
 }
 
 
-static page_t *cluster_ptr = NULL;
+static page_type *cluster_ptr = NULL;
 static unsigned long pages_left = 0;
 
 #endif /* MALLOC_CHECK */
 
 /* Allocate one page (which is initialized to 0).  */
 
-static page_t *
+static page_type *
 allocate_page ()
 {
 #ifndef MALLOC_CHECK
@@ -4797,7 +4862,7 @@ allocate_page ()
 
 #else  /* MALLOC_CHECK */
 
-  page_t *ptr;
+  page_type *ptr;
 
   ptr = xmalloc (PAGE_USIZE);
   memset (ptr, 0, PAGE_USIZE);
@@ -4822,7 +4887,7 @@ allocate_scope ()
   else
     {
       register int unallocated = alloc_counts[(int)alloc_type_scope].unallocated;
-      register page_t *cur_page        = alloc_counts[(int)alloc_type_scope].cur_page;
+      register page_type *cur_page     = alloc_counts[(int)alloc_type_scope].cur_page;
 
       if (unallocated == 0)
        {
@@ -4873,7 +4938,7 @@ allocate_vlinks ()
 #ifndef MALLOC_CHECK
 
   register int unallocated = alloc_counts[(int)alloc_type_vlinks].unallocated;
-  register page_t *cur_page = alloc_counts[(int)alloc_type_vlinks].cur_page;
+  register page_type *cur_page = alloc_counts[(int)alloc_type_vlinks].cur_page;
 
   if (unallocated == 0)
     {
@@ -4907,7 +4972,7 @@ allocate_shash ()
 #ifndef MALLOC_CHECK
 
   register int unallocated = alloc_counts[(int)alloc_type_shash].unallocated;
-  register page_t *cur_page = alloc_counts[(int)alloc_type_shash].cur_page;
+  register page_type *cur_page = alloc_counts[(int)alloc_type_shash].cur_page;
 
   if (unallocated == 0)
     {
@@ -4941,7 +5006,7 @@ allocate_thash ()
 #ifndef MALLOC_CHECK
 
   register int unallocated = alloc_counts[(int)alloc_type_thash].unallocated;
-  register page_t *cur_page = alloc_counts[(int)alloc_type_thash].cur_page;
+  register page_type *cur_page = alloc_counts[(int)alloc_type_thash].cur_page;
 
   if (unallocated == 0)
     {
@@ -4980,7 +5045,7 @@ allocate_tag ()
   else
     {
       register int unallocated = alloc_counts[(int)alloc_type_tag].unallocated;
-      register page_t *cur_page = alloc_counts[(int)alloc_type_tag].cur_page;
+      register page_type *cur_page = alloc_counts[(int)alloc_type_tag].cur_page;
 
       if (unallocated == 0)
        {
@@ -5031,7 +5096,7 @@ allocate_forward ()
 #ifndef MALLOC_CHECK
 
   register int unallocated = alloc_counts[(int)alloc_type_forward].unallocated;
-  register page_t *cur_page = alloc_counts[(int)alloc_type_forward].cur_page;
+  register page_type *cur_page = alloc_counts[(int)alloc_type_forward].cur_page;
 
   if (unallocated == 0)
     {
@@ -5070,7 +5135,7 @@ allocate_thead ()
   else
     {
       register int unallocated = alloc_counts[(int)alloc_type_thead].unallocated;
-      register page_t *cur_page = alloc_counts[(int)alloc_type_thead].cur_page;
+      register page_type *cur_page = alloc_counts[(int)alloc_type_thead].cur_page;
 
       if (unallocated == 0)
        {
@@ -5119,7 +5184,7 @@ allocate_lineno_list ()
 #ifndef MALLOC_CHECK
 
   register int unallocated = alloc_counts[(int)alloc_type_lineno].unallocated;
-  register page_t *cur_page = alloc_counts[(int)alloc_type_lineno].cur_page;
+  register page_type *cur_page = alloc_counts[(int)alloc_type_lineno].cur_page;
 
   if (unallocated == 0)
     {
@@ -5247,7 +5312,7 @@ generate_ecoff_stab (what, string, type, other, desc)
   if (sym != (symbolS *) NULL)
     hold = sym->ecoff_symbol;
 
-  (void) add_ecoff_symbol (string, st, sc, sym, value, indx);
+  (void) add_ecoff_symbol (string, st, sc, sym, (bfd_vma) 0, value, indx);
 
   if (sym != (symbolS *) NULL)
     sym->ecoff_symbol = hold;
@@ -5269,18 +5334,9 @@ ecoff_generate_asm_lineno (filename, 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, 1);
-      generate_asm_lineno = 1;
-    }
+  if (current_stabs_filename == (char *)NULL
+      || strcmp (current_stabs_filename, filename))
+    add_file (filename, 0, 1);
 
   list = allocate_lineno_list ();
 
@@ -5291,6 +5347,9 @@ ecoff_generate_asm_lineno (filename, lineno)
   list->paddr = frag_now_fix ();
   list->lineno = lineno;
 
+  /* We don't want to merge files which have line numbers.  */
+  cur_file_ptr->fdr.fMerge = 0;
+
   /* 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.  */
@@ -5305,34 +5364,10 @@ ecoff_generate_asm_lineno (filename, lineno)
     }
   else
     {
+      last_lineno = list;
       *last_lineno_ptr = list;
       last_lineno_ptr = &list->next;
     }
 }
 
-static int line_label_cnt = 0;
-void
-ecoff_generate_asm_line_stab (filename, lineno)
-    char *filename;
-    int lineno;
-{
-  char *ll;
-
-  if (strcmp (current_stabs_filename, filename)) 
-    {
-      add_file (filename, 0, 1);
-      generate_asm_lineno = 1;
-    }
-
-  line_label_cnt++;
-  /* generate local label $LMnn */
-  ll = xmalloc(10);
-  sprintf(ll, "$LM%d", line_label_cnt);
-  colon (ll);
-
-  /* generate stab for the line */
-  generate_ecoff_stab ('n', ll, N_SLINE, 0, lineno); 
-
-}
-
 #endif /* ECOFF_DEBUGGING */
This page took 0.035352 seconds and 4 git commands to generate.