compiling binutils with -DDEBUG

Alan Modra amodra@bigpond.net.au
Tue Mar 1 02:01:00 GMT 2005


Attempting to building binutils with -DDEBUG (ie. gas know() assertion
does something) is interesting.  Lots more warnings, gas doesn't even
compile, and it's obvious some targets have never been built with
-DDEBUG turned on.  This fixes some of the problems.

bfd/
	* targets.h: Typo fix.
	* bfd-in2.h: Regenerate.
gas/
	* as.h (assert): Warning fix.
	* expr.c (expr): Correct assertion.
	* read.c (s_comm_internal): Remove assertion.
It's not true for .lcomm.
	* write.c (relax_segment): Enable vma assertion only for BFD_ASSEMBLER.
	(fixup_segment): Remove assertion.
Didn't seem worth including struct-symbol.h just for this.  I suspect
the assertion isn't true too, since a similar assertion in obj-coff.c
fails with X_op an O_constant.  Maybe this is a real bug.  Ian, you're
probably the only one who can answer mri mode queries off the top of
your head.  Care to comment?
	* config/tc-dlx.c (machine_ip): Remove untrue assertions.
	(md_apply_fix3): Likewise.
	* config/tc-i370.c (md_begin): Correct assertion.
	(i370_macro): Warning fix for assertion.
	* config/tc-m68k.c (md_assemble): Don't use sizeof host short.
A portability fix that I accidentally left out of the last commit.


Index: bfd/targets.c
===================================================================
RCS file: /cvs/src/src/bfd/targets.c,v
retrieving revision 1.122
diff -u -p -r1.122 targets.c
--- bfd/targets.c	31 Jan 2005 23:13:30 -0000	1.122
+++ bfd/targets.c	1 Mar 2005 01:18:36 -0000
@@ -209,7 +209,7 @@ DESCRIPTION
 .  unsigned short ar_max_namelen;
 .
 .  {* Entries for byte swapping for data. These are different from the
-.     other entry points, since they don't take a BFD asthe first argument.
+.     other entry points, since they don't take a BFD as the first argument.
 .     Certain other handlers could do the same.  *}
 .  bfd_uint64_t   (*bfd_getx64) (const void *);
 .  bfd_int64_t    (*bfd_getx_signed_64) (const void *);
Index: gas/as.h
===================================================================
RCS file: /cvs/src/src/gas/as.h,v
retrieving revision 1.43
diff -u -p -r1.43 as.h
--- gas/as.h	17 Feb 2005 13:46:00 -0000	1.43
+++ gas/as.h	1 Mar 2005 01:18:47 -0000
@@ -104,7 +104,8 @@ extern void *alloca ();
 #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 6)
 #define __PRETTY_FUNCTION__  ((char*)0)
 #endif
-#define assert(P) ((P) ? 0 : (as_assert (__FILE__, __LINE__, __PRETTY_FUNCTION__), 0))
+#define assert(P) \
+  ((void) ((P) ? 0 : (as_assert (__FILE__, __LINE__, __PRETTY_FUNCTION__), 0)))
 #undef abort
 #define abort()		as_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
 
Index: gas/expr.c
===================================================================
RCS file: /cvs/src/src/gas/expr.c,v
retrieving revision 1.52
diff -u -p -r1.52 expr.c
--- gas/expr.c	11 Aug 2004 02:11:57 -0000	1.52
+++ gas/expr.c	1 Mar 2005 01:18:50 -0000
@@ -1716,7 +1716,7 @@ expr (int rankarg,		/* Larger # is highe
       know (op_right == O_illegal
 	    || op_rank[(int) op_right] <= op_rank[(int) op_left]);
       know ((int) op_left >= (int) O_multiply
-	    && (int) op_left <= (int) O_logical_or);
+	    && (int) op_left <= (int) O_index);
 
       /* input_line_pointer->after right-hand quantity.  */
       /* left-hand quantity in resultP.  */
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.93
diff -u -p -r1.93 read.c
--- gas/read.c	23 Feb 2005 02:44:18 -0000	1.93
+++ gas/read.c	1 Mar 2005 01:18:53 -0000
@@ -1472,7 +1472,6 @@ s_comm_internal (int param,
 #endif
     }
 
-  know (symbolP == NULL || symbolP->sy_frag == &zero_address_frag);
   demand_empty_rest_of_line ();
  out:
   if (flag_mri)
Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.83
diff -u -p -r1.83 write.c
--- gas/write.c	1 Mar 2005 00:43:57 -0000	1.83
+++ gas/write.c	1 Mar 2005 01:18:54 -0000
@@ -2395,7 +2395,9 @@ relax_segment (struct frag *segment_frag
                          into the section.  Here it is assumed that the
                          section's VMA is zero, and can omit subtracting it
                          from the symbol's value to get the address offset.  */
-                      know (S_GET_SECTION (symbolP)->vma == 0);
+#ifdef BFD_ASSEMBLER
+                      know (S_GET_SEGMENT (symbolP)->vma == 0);
+#endif
 		      target += S_GET_VALUE (symbolP) * OCTETS_PER_BYTE;
 		    }
 
@@ -2583,7 +2585,6 @@ fixup_segment (fixS *fixP, segT this_seg
       if (fixP->fx_addsy != NULL
 	  && symbol_mri_common_p (fixP->fx_addsy))
 	{
-	  know (fixP->fx_addsy->sy_value.X_op == O_symbol);
 	  add_number += S_GET_VALUE (fixP->fx_addsy);
 	  fixP->fx_offset = add_number;
 	  fixP->fx_addsy
Index: gas/config/tc-dlx.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-dlx.c,v
retrieving revision 1.10
diff -u -p -r1.10 tc-dlx.c
--- gas/config/tc-dlx.c	31 Jan 2005 23:18:27 -0000	1.10
+++ gas/config/tc-dlx.c	1 Mar 2005 01:18:59 -0000
@@ -972,21 +972,18 @@ machine_ip (str)
 	  /* Type 'a' Register.  */
 	case 'a':
 	  /* A general register at bits 21-25, rs1.  */
-	  know (operand->X_op != O_register);
 	  reg_shift = 21;
 	  goto general_reg;
 
 	  /* Type 'b' Register.  */
 	case 'b':
 	  /* A general register at bits 16-20, rs2/rd.  */
-	  know (operand->X_op != O_register);
 	  reg_shift = 16;
 	  goto general_reg;
 
 	  /* Type 'c' Register.  */
 	case 'c':
 	  /* A general register at bits 11-15, rd.  */
-	  know (operand->X_op != O_register);
 	  reg_shift = 11;
 
 	general_reg:
@@ -1135,9 +1132,6 @@ md_apply_fix3 (fixP, valP, seg)
   long val = *valP;
   char *place = fixP->fx_where + fixP->fx_frag->fr_literal;
 
-  know (fixP->fx_size == 4);
-  know (fixP->fx_r_type < NO_RELOC);
-
   switch (fixP->fx_r_type)
     {
     case RELOC_DLX_LO16:
Index: gas/config/tc-i370.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-i370.c,v
retrieving revision 1.23
diff -u -p -r1.23 tc-i370.c
--- gas/config/tc-i370.c	23 Feb 2005 12:28:04 -0000	1.23
+++ gas/config/tc-i370.c	1 Mar 2005 01:18:59 -0000
@@ -588,7 +588,8 @@ md_begin ()
    op_end = i370_opcodes + i370_num_opcodes;
    for (op = i370_opcodes; op < op_end; op++)
      {
-       know ((op->opcode & op->mask) == op->opcode);
+       know ((op->opcode.i[0] & op->mask.i[0]) == op->opcode.i[0]
+	     && (op->opcode.i[1] & op->mask.i[1]) == op->opcode.i[1]);
 
        if ((op->flags & i370_cpu) != 0)
          {
@@ -2422,7 +2423,7 @@ i370_macro (str, macro)
       else
         {
           arg = strtol (format + 1, &send, 10);
-          know (send != format && arg >= 0 && arg < count);
+          know (send != format && arg >= 0 && (unsigned) arg < count);
           len += strlen (operands[arg]);
           format = send;
         }
Index: gas/config/tc-m68k.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-m68k.c,v
retrieving revision 1.61
diff -u -p -r1.61 tc-m68k.c
--- gas/config/tc-m68k.c	17 Feb 2005 13:46:03 -0000	1.61
+++ gas/config/tc-m68k.c	1 Mar 2005 01:19:03 -0000
@@ -4067,7 +4067,7 @@ md_assemble (char *str)
   shorts_this_frag = 0;
   if (n)
     {
-      toP = frag_more (n * sizeof (short));
+      toP = frag_more (n * 2);
       while (n--)
 	{
 	  md_number_to_chars (toP, (long) (*fromP), 2);

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list