This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: MIPS ABI problems


On Sat, Jun 08, 2002 at 05:53:54PM +0200, Thiemo Seufer wrote:
> Daniel Jacobowitz wrote:
> > Thiemo,
> > 
> > Did you run the testsuite after the last batch of ABI "cleanups"?
> 
> I did so over my whole patch before I singled out the approved parts
> again.
> 
> > It
> > fails all over the place now, and it looks much like it did the last
> > time that we had a disagreement about what should be tagged how. 
> 
> Must be some sort of silly bug. I'll look into it tonight. Sorry
> for breaking things again. :-(

Actually, I think they are my fault :(  I messeed up analyzing what my
patch did.  The line:

-#define ECOFF_DEBUGGING 1
+#define ECOFF_DEBUGGING (debug_type == DEBUG_ECOFF)

turned off generation of .mdebug sections implicitly in the presence of
stabs.  In fact, it turned off generation of .mdebug sections for ELF
entirely.  That's something I've always wanted to do, but certainly not
what I was trying to do here :(

The only way I see to make this work is to switch to stabs-in-elf for
ELF targets.  The only platforms I really expect to be affected by this
are the *BSDs; GNU/Linux already switched, and mips-elf tools can
probably cope.  Jason, mind checking this patch through a gas/gdb
testsuite on NetBSD/MIPS?

I need to double-check how this interacts with GCC.  It turns -g into a
no-op, but guess what?  -g was already a no-op as far as I can tell. 
gas has only ever recognized '--gdwarf2' and '--gstabs'.  The only time
the value of -g is checked is:
void
mips_frob_file_before_adjust ()
{
#ifndef NO_ECOFF_DEBUGGING
  if (ECOFF_DEBUGGING
      && mips_debug != 0
      && ! ecoff_debugging_seen)
    flag_keep_locals = 1;
#endif
}

The only test of -g was lineno.s, and it has been marked XFAIL for the
only (tested) target to use non-ecoff debugging:
    # Linux uses ELF stabs, which doesn't support line number.
    setup_xfail "mips*-*-*linux*"
    run_dump_test "lineno"
(VxWorks is the other, by the way.)  The comment is wrong; ELF stabs
certainly support line numbers.  We just hadn't implemented it; it was
quite easy.

What does this tell me?  It tells me that I shouldn't feel too guilty
about turning off line numbers with 'as -g' on mips-elf.  I assume
ECOFF debugging information always defaulted to including line numbers
and defaulted to on, and comments in ecoff.c agree with that.  I doubt
the -g that lineno.d passed was even necessary.

This patch:
  Fixes --gstabs for outputting function names.
  Uses --gstabs instead of -g on lineno.d, and kills the xfail.
  Generates a .pdr section any time we are not generating ecoff debug
info, so that the necessary information will be available to debuggers.
  Eliminates all uses of MIPS_STABS_ELF, and defaults to it in the
absence of ECOFF_DEBUGGING==1.

I will send a followup patch to remove the definitions of
MIPS_STABS_ELF if this goes in.  It's still used to control the default
value of ECOFF_DEBUGGING, but that's it.

I'd love to kill ECOFF_DEBUGGING.  In fact, if this patch works on
*BSD, I think we can do so.  Thoughts?

--  
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2002-06-08  Daniel Jacobowitz  <drow@mvista.com>

	* config/tc-mips.c (mips_pseudo_table): Remove #ifdef around
	".extern".
	(pdr_seg): Declare unconditionally.
	(md_begin): Always generate .pdr unless ECOFF_DEBUGGING or not ELF.
	(s_mips_end): Likewise.  Generate stabs function markers.
	(s_mips_ent): Generate stabs function markers.
	(s_mips_frame): Always generate .pdr unless ECOFF_DEBUGGING or not
	ELF.
	(s_mips_mask): Likewise.

2002-06-08  Daniel Jacobowitz  <drow@mvista.com>

	* gas/mips/lineno.d: Use --gstabs.
	* gas/mips/mips.exp (lineno.s): Remove XFAIL.

Index: config/tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.142
diff -u -p -u -p -r1.142 tc-mips.c
--- config/tc-mips.c	8 Jun 2002 07:37:15 -0000	1.142
+++ config/tc-mips.c	8 Jun 2002 18:44:16 -0000
@@ -885,9 +885,7 @@ static const pseudo_typeS mips_pseudo_ta
   {"text", s_change_sec, 't'},
   {"word", s_cons, 2},
 
-#ifdef MIPS_STABS_ELF
   { "extern", ecoff_directive_extern, 0},
-#endif
 
   { NULL, NULL, 0 },
 };
@@ -967,11 +965,10 @@ static boolean imm_unmatched_hi;
 
 static boolean mips16_small, mips16_ext;
 
-#ifdef MIPS_STABS_ELF
-/* The pdr segment for per procedure frame/regmask info */
+/* The pdr segment for per procedure frame/regmask info.  Not used for
+   ECOFF debugging.  */
 
 static segT pdr_seg;
-#endif
 
 static const char *
 mips_isa_to_str (isa)
@@ -1224,12 +1221,15 @@ md_begin ()
 					  SEC_HAS_CONTENTS | SEC_READONLY);
 	    (void) bfd_set_section_alignment (stdoutput, sec, 2);
 	  }
-
-#ifdef MIPS_STABS_ELF
-	pdr_seg = subseg_new (".pdr", (subsegT) 0);
-	(void) bfd_set_section_flags (stdoutput, pdr_seg,
-			     SEC_READONLY | SEC_RELOC | SEC_DEBUGGING);
-	(void) bfd_set_section_alignment (stdoutput, pdr_seg, 2);
+#ifdef OBJ_ELF
+	else if (OUTPUT_FLAVOR == bfd_target_elf_flavour)
+	  {
+	    pdr_seg = subseg_new (".pdr", (subsegT) 0);
+	    (void) bfd_set_section_flags (stdoutput, pdr_seg,
+					  SEC_READONLY | SEC_RELOC
+					  | SEC_DEBUGGING);
+	    (void) bfd_set_section_alignment (stdoutput, pdr_seg, 2);
+	  }
 #endif
 
 	subseg_set (seg, subseg);
@@ -13433,46 +13433,52 @@ s_mips_end (x)
       assert (S_GET_NAME (p));
       if (strcmp (S_GET_NAME (p), S_GET_NAME (cur_proc_ptr->isym)))
 	as_warn (_(".end symbol does not match .ent symbol."));
+
+      if (debug_type == DEBUG_STABS)
+	stabs_generate_asm_endfunc (S_GET_NAME (p),
+				    S_GET_NAME (p));
     }
   else
     as_warn (_(".end directive missing or unknown symbol"));
 
-#ifdef MIPS_STABS_ELF
-  {
-    segT saved_seg = now_seg;
-    subsegT saved_subseg = now_subseg;
-    valueT dot;
-    expressionS exp;
-    char *fragp;
+#ifdef OBJ_ELF
+  /* Generate a .pdr section.  */
+  if (OUTPUT_FLAVOR == bfd_target_elf_flavour && ! ECOFF_DEBUGGING)
+    {
+      segT saved_seg = now_seg;
+      subsegT saved_subseg = now_subseg;
+      valueT dot;
+      expressionS exp;
+      char *fragp;
 
-    dot = frag_now_fix ();
+      dot = frag_now_fix ();
 
 #ifdef md_flush_pending_output
-    md_flush_pending_output ();
+      md_flush_pending_output ();
 #endif
 
-    assert (pdr_seg);
-    subseg_set (pdr_seg, 0);
+      assert (pdr_seg);
+      subseg_set (pdr_seg, 0);
 
-    /* Write the symbol.  */
-    exp.X_op = O_symbol;
-    exp.X_add_symbol = p;
-    exp.X_add_number = 0;
-    emit_expr (&exp, 4);
-
-    fragp = frag_more (7 * 4);
-
-    md_number_to_chars (fragp,      (valueT) cur_proc_ptr->reg_mask, 4);
-    md_number_to_chars (fragp +  4, (valueT) cur_proc_ptr->reg_offset, 4);
-    md_number_to_chars (fragp +  8, (valueT) cur_proc_ptr->fpreg_mask, 4);
-    md_number_to_chars (fragp + 12, (valueT) cur_proc_ptr->fpreg_offset, 4);
-    md_number_to_chars (fragp + 16, (valueT) cur_proc_ptr->frame_offset, 4);
-    md_number_to_chars (fragp + 20, (valueT) cur_proc_ptr->frame_reg, 4);
-    md_number_to_chars (fragp + 24, (valueT) cur_proc_ptr->pc_reg, 4);
-
-    subseg_set (saved_seg, saved_subseg);
-  }
-#endif /* MIPS_STABS_ELF */
+      /* Write the symbol.  */
+      exp.X_op = O_symbol;
+      exp.X_add_symbol = p;
+      exp.X_add_number = 0;
+      emit_expr (&exp, 4);
+
+      fragp = frag_more (7 * 4);
+
+      md_number_to_chars (fragp,      (valueT) cur_proc_ptr->reg_mask, 4);
+      md_number_to_chars (fragp +  4, (valueT) cur_proc_ptr->reg_offset, 4);
+      md_number_to_chars (fragp +  8, (valueT) cur_proc_ptr->fpreg_mask, 4);
+      md_number_to_chars (fragp + 12, (valueT) cur_proc_ptr->fpreg_offset, 4);
+      md_number_to_chars (fragp + 16, (valueT) cur_proc_ptr->frame_offset, 4);
+      md_number_to_chars (fragp + 20, (valueT) cur_proc_ptr->frame_reg, 4);
+      md_number_to_chars (fragp + 24, (valueT) cur_proc_ptr->pc_reg, 4);
+
+      subseg_set (saved_seg, saved_subseg);
+    }
+#endif /* OBJ_ELF */
 
   cur_proc_ptr = NULL;
 }
@@ -13526,6 +13532,10 @@ s_mips_ent (aent)
       symbol_get_bfdsym (symbolP)->flags |= BSF_FUNCTION;
 
       ++numprocs;
+
+      if (debug_type == DEBUG_STABS)
+        stabs_generate_asm_func (S_GET_NAME (symbolP),
+				 S_GET_NAME (symbolP));
     }
 
   demand_empty_rest_of_line ();
@@ -13541,36 +13551,38 @@ static void
 s_mips_frame (ignore)
      int ignore ATTRIBUTE_UNUSED;
 {
-#ifdef MIPS_STABS_ELF
+#ifdef OBJ_ELF
+  if (OUTPUT_FLAVOR == bfd_target_elf_flavour && ! ECOFF_DEBUGGING)
+    {
+      long val;
 
-  long val;
+      if (cur_proc_ptr == (procS *) NULL)
+	{
+	  as_warn (_(".frame outside of .ent"));
+	  demand_empty_rest_of_line ();
+	  return;
+	}
 
-  if (cur_proc_ptr == (procS *) NULL)
-    {
-      as_warn (_(".frame outside of .ent"));
-      demand_empty_rest_of_line ();
-      return;
-    }
+      cur_proc_ptr->frame_reg = tc_get_register (1);
 
-  cur_proc_ptr->frame_reg = tc_get_register (1);
+      SKIP_WHITESPACE ();
+      if (*input_line_pointer++ != ','
+	  || get_absolute_expression_and_terminator (&val) != ',')
+	{
+	  as_warn (_("Bad .frame directive"));
+	  --input_line_pointer;
+	  demand_empty_rest_of_line ();
+	  return;
+	}
+
+      cur_proc_ptr->frame_offset = val;
+      cur_proc_ptr->pc_reg = tc_get_register (0);
 
-  SKIP_WHITESPACE ();
-  if (*input_line_pointer++ != ','
-      || get_absolute_expression_and_terminator (&val) != ',')
-    {
-      as_warn (_("Bad .frame directive"));
-      --input_line_pointer;
       demand_empty_rest_of_line ();
-      return;
     }
-
-  cur_proc_ptr->frame_offset = val;
-  cur_proc_ptr->pc_reg = tc_get_register (0);
-
-  demand_empty_rest_of_line ();
-#else
-  s_ignore (ignore);
-#endif /* MIPS_STABS_ELF */
+  else
+#endif /* OBJ_ELF */
+    s_ignore (ignore);
 }
 
 /* The .fmask and .mask directives. If the mdebug section is present
@@ -13583,41 +13595,44 @@ static void
 s_mips_mask (reg_type)
      char reg_type;
 {
-#ifdef MIPS_STABS_ELF
-  long mask, off;
-
-  if (cur_proc_ptr == (procS *) NULL)
+#ifdef OBJ_ELF
+  if (OUTPUT_FLAVOR == bfd_target_elf_flavour && ! ECOFF_DEBUGGING)
     {
-      as_warn (_(".mask/.fmask outside of .ent"));
-      demand_empty_rest_of_line ();
-      return;
-    }
+      long mask, off;
 
-  if (get_absolute_expression_and_terminator (&mask) != ',')
-    {
-      as_warn (_("Bad .mask/.fmask directive"));
-      --input_line_pointer;
-      demand_empty_rest_of_line ();
-      return;
-    }
+      if (cur_proc_ptr == (procS *) NULL)
+	{
+	  as_warn (_(".mask/.fmask outside of .ent"));
+	  demand_empty_rest_of_line ();
+	  return;
+	}
+
+      if (get_absolute_expression_and_terminator (&mask) != ',')
+	{
+	  as_warn (_("Bad .mask/.fmask directive"));
+	  --input_line_pointer;
+	  demand_empty_rest_of_line ();
+	  return;
+	}
 
-  off = get_absolute_expression ();
+      off = get_absolute_expression ();
 
-  if (reg_type == 'F')
-    {
-      cur_proc_ptr->fpreg_mask = mask;
-      cur_proc_ptr->fpreg_offset = off;
+      if (reg_type == 'F')
+	{
+	  cur_proc_ptr->fpreg_mask = mask;
+	  cur_proc_ptr->fpreg_offset = off;
+	}
+      else
+	{
+	  cur_proc_ptr->reg_mask = mask;
+	  cur_proc_ptr->reg_offset = off;
+	}
+
+      demand_empty_rest_of_line ();
     }
   else
-    {
-      cur_proc_ptr->reg_mask = mask;
-      cur_proc_ptr->reg_offset = off;
-    }
-
-  demand_empty_rest_of_line ();
-#else
-  s_ignore (reg_type);
-#endif /* MIPS_STABS_ELF */
+#endif /* OBJ_ELF */
+    s_ignore (reg_type);
 }
 
 /* The .loc directive.  */
Index: testsuite/gas/mips/lineno.d
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/lineno.d,v
retrieving revision 1.3
diff -u -p -u -p -r1.3 lineno.d
--- testsuite/gas/mips/lineno.d	29 Jun 2001 21:27:43 -0000	1.3
+++ testsuite/gas/mips/lineno.d	8 Jun 2002 18:44:19 -0000
@@ -1,6 +1,6 @@
 #objdump: -d -l -mmips:4000
 #name: assembly line numbers
-#as: -g -march=r4000
+#as: --gstabs -march=r4000
 
 
 .*: +file format .*mips.*
Index: testsuite/gas/mips/mips.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/mips/mips.exp,v
retrieving revision 1.36
diff -u -p -u -p -r1.36 mips.exp
--- testsuite/gas/mips/mips.exp	31 May 2002 18:27:02 -0000	1.36
+++ testsuite/gas/mips/mips.exp	8 Jun 2002 18:44:19 -0000
@@ -145,8 +145,6 @@ if { [istarget mips*-*-*] } then {
     run_dump_test "mips4650"
     run_dump_test "mips4100"
     run_dump_test "perfcount"
-    # Linux uses ELF stabs, which doesn't support line number.
-    setup_xfail "mips*-*-*linux*"
     run_dump_test "lineno"
     run_dump_test "sync"
     run_dump_test "mips32"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]