* mipsread.c (fixup_sigtramp): Initialize pdr.adr, it is used by
[binutils-gdb.git] / gdb / mipsread.c
index d0766997bd6e77f701b33dabc0d206b6c2359b01..da6f071e0bbaf23d269e9d656f7a6bfe28ad8395 100644 (file)
@@ -95,9 +95,6 @@ typedef struct mips_extra_func_info {
 /* FIXME: coff/internal.h and aout/aout64.h both define N_ABS.  We
    want the definition from aout/aout64.h.  */
 #undef N_ABS
-/* FIXME: coff/mips.h and aout/aout64.h both define ZMAGIC.  We don't
-   use it.  */
-#undef ZMAGIC
 
 #include "libaout.h"           /* Private BFD a.out information.  */
 #include "aout/aout64.h"
@@ -1518,20 +1515,19 @@ upgrade_type (tpp, tq, ax, bigend)
    images that have been partially stripped (ld -x) have been deprived
    of local symbols, and we have to cope with them here.  FIRST_OFF is
    the offset of the first procedure for this FDR; we adjust the
-   address by this amount, but I don't know why.
+   address by this amount, but I don't know why.  SEARCH_SYMTAB is the symtab
+   to look for the function which contains the MIPS_EFI_SYMBOL_NAME symbol
+   in question, or NULL to use top_stack->cur_block.  */
 
-   EFI_SYMBOL is the MIPS_EFI_SYMBOL_NAME symbol to use, or NULL which
-   means to look up the name using the block in top_stack.  */
-
-static void parse_procedure PARAMS ((PDR *, struct symbol *, unsigned long));
+static void parse_procedure PARAMS ((PDR *, struct symtab *, unsigned long));
 
 static void
-parse_procedure (pr, efi_symbol, first_off)
+parse_procedure (pr, search_symtab, first_off)
      PDR *pr;
-     struct symbol *efi_symbol;
+     struct symtab *search_symtab;
      unsigned long first_off;
 {
-  struct symbol *s;
+  struct symbol *s, *i;
   struct block *b;
   struct mips_extra_func_info *e;
   char *sh_name;
@@ -1569,50 +1565,66 @@ parse_procedure (pr, efi_symbol, first_off)
       sh_name = ecoff_data (cur_bfd)->ss + cur_fdr->issBase + sh.iss;
     }
 
-  if (efi_symbol == NULL)
+  if (search_symtab != NULL)
     {
-      /* OK, first find the function.  */
-
-      s = mylookup_symbol (sh_name, top_stack->cur_block,
-                          VAR_NAMESPACE, LOC_BLOCK);
+#if 0
+      /* This loses both in the case mentioned (want a static, find a global),
+        but also if we are looking up a non-mangled name which happens to
+        match the name of a mangled function.  */
+      /* We have to save the cur_fdr across the call to lookup_symbol.
+        If the pdr is for a static function and if a global function with
+        the same name exists, lookup_symbol will eventually read in the symtab
+        for the global function and clobber cur_fdr.  */
+      FDR *save_cur_fdr = cur_fdr;
+      s = lookup_symbol (sh_name, NULL, VAR_NAMESPACE, 0, NULL);
+      cur_fdr = save_cur_fdr;
+#else
+      s = mylookup_symbol
+       (sh_name,
+        BLOCKVECTOR_BLOCK (BLOCKVECTOR (search_symtab), STATIC_BLOCK),
+        VAR_NAMESPACE,
+        LOC_BLOCK);
+#endif
+    }
+  else
+    s = mylookup_symbol (sh_name, top_stack->cur_block,
+                        VAR_NAMESPACE, LOC_BLOCK);
 
-      if (s != 0)
-       {
-         b = SYMBOL_BLOCK_VALUE (s);
-       }
-      else
-       {
-         complain (&pdr_for_nonsymbol_complaint, sh_name);
+  if (s != 0)
+    {
+      b = SYMBOL_BLOCK_VALUE (s);
+    }
+  else
+    {
+      complain (&pdr_for_nonsymbol_complaint, sh_name);
 #if 1
-         return;
+      return;
 #else
 /* FIXME -- delete.  We can't do symbol allocation now; it's all done.  */
-         s = new_symbol (sh_name);
-         SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
-         SYMBOL_CLASS (s) = LOC_BLOCK;
-         /* Donno its type, hope int is ok */
-         SYMBOL_TYPE (s) = lookup_function_type (builtin_type_int);
-         add_symbol (s, top_stack->cur_block);
-         /* Wont have symbols for this one */
-         b = new_block (2);
-         SYMBOL_BLOCK_VALUE (s) = b;
-         BLOCK_FUNCTION (b) = s;
-         BLOCK_START (b) = pr->adr;
-         /* BOUND used to be the end of procedure's text, but the
-            argument is no longer passed in.  */
-         BLOCK_END (b) = bound;
-         BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
-         add_block (b, top_stack->cur_st);
+      s = new_symbol (sh_name);
+      SYMBOL_NAMESPACE (s) = VAR_NAMESPACE;
+      SYMBOL_CLASS (s) = LOC_BLOCK;
+      /* Donno its type, hope int is ok */
+      SYMBOL_TYPE (s) = lookup_function_type (builtin_type_int);
+      add_symbol (s, top_stack->cur_block);
+      /* Wont have symbols for this one */
+      b = new_block (2);
+      SYMBOL_BLOCK_VALUE (s) = b;
+      BLOCK_FUNCTION (b) = s;
+      BLOCK_START (b) = pr->adr;
+      /* BOUND used to be the end of procedure's text, but the
+        argument is no longer passed in.  */
+      BLOCK_END (b) = bound;
+      BLOCK_SUPERBLOCK (b) = top_stack->cur_block;
+      add_block (b, top_stack->cur_st);
 #endif
-       }
-
-      efi_symbol = mylookup_symbol
-       (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE, LOC_CONST);
     }
 
-  if (efi_symbol)
+  i = mylookup_symbol (MIPS_EFI_SYMBOL_NAME, b, LABEL_NAMESPACE, LOC_CONST);
+
+  if (i)
     {
-      e = (struct mips_extra_func_info *) SYMBOL_VALUE (efi_symbol);
+      e = (struct mips_extra_func_info *) SYMBOL_VALUE (i);
       e->pdr = *pr;
       e->pdr.isym = (long) s;
       e->pdr.adr += cur_fdr->adr - first_off;
@@ -2458,23 +2470,12 @@ psymtab_to_symtab_1 (pst, filename)
 
   if (processing_gcc_compilation != 0)
     {
-      /* This symbol table contains stabs-in-ecoff entries.  */
-
       struct pdr_ext *pdr_ptr;
       struct pdr_ext *pdr_end;
       int first_pdr;
       unsigned long first_off;
-      struct cleanup *old_cleanups;
-
-      /* Given a symbol index in the symbol file, find the
-        MIPS_EFI_SYMBOL_NAME symbol which goes with it.  If this is taking
-        up too much memory, we could get fancy with hash tables or some
-        such.  */
-      struct symbol **mips_func_info_by_isym;
 
-      mips_func_info_by_isym = (struct symbol **)
-       xmalloc (fh->csym * sizeof (*mips_func_info_by_isym));
-      old_cleanups = make_cleanup (free, mips_func_info_by_isym);
+      /* This symbol table contains stabs-in-ecoff entries.  */
 
       /* Parse local symbols first */
 
@@ -2515,7 +2516,6 @@ psymtab_to_symtab_1 (pst, filename)
                  SYMBOL_TYPE (s) = builtin_type_void;
                  SYMBOL_VALUE (s) = (int) e;
                  add_symbol_to_list (s, &local_symbols);
-                 mips_func_info_by_isym[cur_sdx] = s;
                }
            }
          else if (sh.st == stLabel && sh.index != indexNil)
@@ -2553,10 +2553,8 @@ psymtab_to_symtab_1 (pst, filename)
              first_off = pr.adr;
              first_pdr = 0;
            }
-         parse_procedure (&pr, mips_func_info_by_isym [pr.isym], first_off);
+         parse_procedure (&pr, st, first_off);
        }
-
-      do_cleanups (old_cleanups);
     }
   else
     {
@@ -3260,6 +3258,7 @@ fixup_sigtramp ()
     e->pdr.fregmask = -1;
     e->pdr.fregoffset = -(7 * sizeof (int));
     e->pdr.isym = (long) s;
+    e->pdr.adr = sigtramp_address;
 
     current_objfile = st->objfile;     /* Keep new_symbol happy */
     s = new_symbol (MIPS_EFI_SYMBOL_NAME);