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]

[RFA:] tc-sh.c: stabilize frag for erroneous code.


With the following code, you get the error message seen in the context of
the patch, followed by an assert failure, since the frag was supposed to be
uhm... converted.  The error message is expected, the crash is not.  It
seems best to stabilize the frag by adding in the variant part to the
fixed part.  Using as_bad_where lets us get a grip on the location of the
error.

Patch will follow for dg framework to run the testcase included here.


! { dg-do assemble }

! Check that errors are emitted, with no crashes, when an external symbol
! is referenced in a conditional or unconditional branch.
start:
	nop
	bt externsym1	! { dg-error "undefined symbol" }
	nop
	bra externsym2	! { dg-error "undefined symbol" }
	nop


Ok to commit?

	* config/tc-sh.c (md_convert_frag) <undefined symbol, conditional
	jump>: Use as_bad_where	instead of as_bad.  Tweak error message
	accordingly.  Stabilize frag by updating fix part and resetting
	variant part.
	<undefined symbol, unconditional jump>: Ditto.

Index: tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.28
diff -p -c -r1.28 tc-sh.c
*** tc-sh.c	2000/11/17 08:47:52	1.28
--- tc-sh.c	2000/11/25 01:27:55
*************** md_convert_frag (headers, seg, fragP)
*** 2391,2407 ****
      case C (UNCOND_JUMP, UNCOND32):
      case C (UNCOND_JUMP, UNDEF_WORD_DISP):
        if (fragP->fr_symbol == NULL)
! 	as_bad (_("at 0x%lx, displacement overflows 12-bit field"),
! 		(unsigned long) fragP->fr_address);
        else if (S_IS_DEFINED (fragP->fr_symbol))
! 	as_bad (_("at 0x%lx, displacement to defined symbol %s overflows 12-bit field"),
! 		(unsigned long) fragP->fr_address,
! 		S_GET_NAME (fragP->fr_symbol));
        else
! 	as_bad (_("at 0x%lx, displacement to undefined symbol %s overflows 12-bit field"),
! 		(unsigned long) fragP->fr_address,
! 		S_GET_NAME (fragP->fr_symbol));
! 
        break;
  
      case C (COND_JUMP, COND12):
--- 2391,2409 ----
      case C (UNCOND_JUMP, UNCOND32):
      case C (UNCOND_JUMP, UNDEF_WORD_DISP):
        if (fragP->fr_symbol == NULL)
! 	as_bad_where (fragP->fr_file, fragP->fr_line,
! 		      _("displacement overflows 12-bit field"));
        else if (S_IS_DEFINED (fragP->fr_symbol))
! 	as_bad_where (fragP->fr_file, fragP->fr_line,
! 		      _("displacement to defined symbol %s overflows 12-bit field"),
! 		      S_GET_NAME (fragP->fr_symbol));
        else
! 	as_bad_where (fragP->fr_file, fragP->fr_line,
! 		      _("displacement to undefined symbol %s overflows 12-bit field"),
! 		      S_GET_NAME (fragP->fr_symbol));
!       /* Stabilize this frag, so we don't trip an assert.  */
!       fragP->fr_fix += fragP->fr_var;
!       fragP->fr_var = 0;
        break;
  
      case C (COND_JUMP, COND12):
*************** md_convert_frag (headers, seg, fragP)
*** 2474,2489 ****
      case C (COND_JUMP, UNDEF_WORD_DISP):
      case C (COND_JUMP_DELAY, UNDEF_WORD_DISP):
        if (fragP->fr_symbol == NULL)
! 	as_bad (_("at 0x%lx, displacement overflows 8-bit field"),
! 		(unsigned long) fragP->fr_address);
        else if (S_IS_DEFINED (fragP->fr_symbol))
! 	as_bad (_("at 0x%lx, displacement to defined symbol %s overflows 8-bit field "),
! 		(unsigned long) fragP->fr_address,
! 		S_GET_NAME (fragP->fr_symbol));
        else
! 	as_bad (_("at 0x%lx, displacement to undefined symbol %s overflows 8-bit field "),
! 		(unsigned long) fragP->fr_address,
! 		S_GET_NAME (fragP->fr_symbol));
        break;
  
      default:
--- 2476,2494 ----
      case C (COND_JUMP, UNDEF_WORD_DISP):
      case C (COND_JUMP_DELAY, UNDEF_WORD_DISP):
        if (fragP->fr_symbol == NULL)
! 	as_bad_where (fragP->fr_file, fragP->fr_line,
! 		      _("displacement overflows 8-bit field"));
        else if (S_IS_DEFINED (fragP->fr_symbol))
! 	as_bad_where (fragP->fr_file, fragP->fr_line,
! 		      _("displacement to defined symbol %s overflows 8-bit field"),
! 		      S_GET_NAME (fragP->fr_symbol));
        else
! 	as_bad_where (fragP->fr_file, fragP->fr_line,
! 		      _("displacement to undefined symbol %s overflows 8-bit field "),
! 		      S_GET_NAME (fragP->fr_symbol));
!       /* Stabilize this frag, so we don't trip an assert.  */
!       fragP->fr_fix += fragP->fr_var;
!       fragP->fr_var = 0;
        break;
  
      default:

brgds, H-P


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