c_gen.pl: Change to use data type "int" instead of "long int" in
[deliverable/binutils-gdb.git] / gas / ecoff.c
index 960032ea0dba7b3994a2fcdde0d06fa8880ef981..082192230373e78a43057751a893a8130442e1ce 100644 (file)
@@ -977,11 +977,7 @@ static const efdr_t init_file =
     langC,             /* lang:        language for this file */
     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 */
@@ -1050,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 */
@@ -1473,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));
@@ -1530,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 ();
@@ -2219,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)
@@ -2323,23 +2322,6 @@ 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),
-                                  (bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SO));
-          (void) add_ecoff_symbol ("void:t1=1", st_Nil, sc_Nil,
-                                  (symbolS *) NULL, (bfd_vma) 0, 0,
-                                  ECOFF_MARK_STAB (N_LSYM));
-       }
-#endif
     }
 }
 
@@ -2354,7 +2336,11 @@ ecoff_new_file (name)
   if (cur_file_ptr != NULL && strcmp (cur_file_ptr->name, name) == 0)
     return;
   add_file (name, 0, 0);
-  generate_asm_lineno = 1;
+
+  /* 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
@@ -3062,25 +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,
-                              symbol_new ("L0\001", now_seg,
-                                          (valueT) frag_now_fix (),
-                                          frag_now),
-                              (bfd_vma) 0, (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, (bfd_vma) 0, 0,
-                                  ECOFF_MARK_STAB (N_FUN));
-       }
-    }
+    (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
+                            symbol_new ("L0\001", now_seg,
+                                        (valueT) frag_now_fix (),
+                                        frag_now),
+                            (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
 
   cur_proc_ptr = (proc_t *) NULL;
 
@@ -3612,8 +3584,7 @@ ecoff_stab (sec, what, string, type, other, desc)
            }
          else
            {
-             as_bad (".stabs expression too complex");
-             sym = NULL;
+             sym = make_expr_symbol (&exp);
              value = 0;
              addend = 0;
            }
@@ -4165,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
@@ -4231,6 +4207,12 @@ 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);
@@ -4291,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;
                    }
                }
            }
@@ -4835,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)
@@ -4852,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
@@ -4875,7 +4862,7 @@ allocate_page ()
 
 #else  /* MALLOC_CHECK */
 
-  page_t *ptr;
+  page_type *ptr;
 
   ptr = xmalloc (PAGE_USIZE);
   memset (ptr, 0, PAGE_USIZE);
@@ -4900,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)
        {
@@ -4951,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)
     {
@@ -4985,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)
     {
@@ -5019,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)
     {
@@ -5058,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)
        {
@@ -5109,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)
     {
@@ -5148,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)
        {
@@ -5197,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)
     {
@@ -5347,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 ();
 
@@ -5392,29 +5370,4 @@ ecoff_generate_asm_lineno (filename, lineno)
     }
 }
 
-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.030165 seconds and 4 git commands to generate.