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]

Improve .COMM error messages


Hi Guys,

  I am applying the patch below in response to the recent thread about
  gas being unable to handle .COMM directives with very large values.
  
  It changes the generic error message so read "out of range" instead
  of "< 0" so that very large values will not be erroneous reported as
  negative.  It also changes the sparc specific .comm handler code in
  a similar fashion, and updates the types used in write.c so that if
  a 64-bit platform is targeted, .COMM values up to 2^63 can be
  supported.
  
Cheers
        Nick

2003-06-24  Nick Clifton  <nickc@redhat.com>

	* read.c (s_comm): Change error message to assume an unsigned size
	has been passed to .comm.
	* config/tc-sparc.c (s_common): Likewise.
	* write.c (write_contents): Replace 'unsigned long' with
	'addressT' and 'long' with offsetT in order to allow computations
	with very large values to work for 64-bit addressed targets.
	(relax_and_size_all_segments): Likewise.
	(relax_frag): Likewise.
	(relax_segment): Likewise.
	
Index: gas/read.c
===================================================================
RCS file: /cvs/src/src/gas/read.c,v
retrieving revision 1.64
diff -c -3 -p -r1.64 read.c
*** gas/read.c	11 Jun 2003 23:16:57 -0000	1.64
--- gas/read.c	24 Jun 2003 10:49:58 -0000
*************** s_comm (ignore)
*** 1389,1395 ****
  
    if ((temp = get_absolute_expression ()) < 0)
      {
!       as_warn (_(".COMMon length (%ld) < 0 ignored"), (long) temp);
        ignore_rest_of_line ();
        if (flag_mri)
  	mri_comment_end (stop, stopc);
--- 1389,1396 ----
  
    if ((temp = get_absolute_expression ()) < 0)
      {
!       as_warn (_(".COMMon length (%lu) out of range ignored"),
! 	       (unsigned long) temp);
        ignore_rest_of_line ();
        if (flag_mri)
  	mri_comment_end (stop, stopc);

Index: gas/config/tc-sparc.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sparc.c,v
retrieving revision 1.47
diff -c -3 -p -r1.47 tc-sparc.c
*** gas/config/tc-sparc.c	21 May 2003 12:07:55 -0000	1.47
--- gas/config/tc-sparc.c	24 Jun 2003 10:50:18 -0000
*************** s_common (ignore)
*** 3764,3770 ****
    char *name;
    char c;
    char *p;
!   int temp, size;
    symbolS *symbolP;
  
    name = input_line_pointer;
--- 3764,3770 ----
    char *name;
    char c;
    char *p;
!   offsetT temp, size;
    symbolS *symbolP;
  
    name = input_line_pointer;
*************** s_common (ignore)
*** 3785,3791 ****
  
    if ((temp = get_absolute_expression ()) < 0)
      {
!       as_bad (_(".COMMon length (%d.) <0! Ignored."), temp);
        ignore_rest_of_line ();
        return;
      }
--- 3785,3792 ----
  
    if ((temp = get_absolute_expression ()) < 0)
      {
!       as_bad (_(".COMMon length (%lu) out of range ignored"),
! 	      (unsigned long) temp);
        ignore_rest_of_line ();
        return;
      }

Index: gas/write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.72
diff -c -3 -p -r1.72 write.c
*** gas/write.c	11 Jun 2003 10:32:08 -0000	1.72
--- gas/write.c	24 Jun 2003 10:50:01 -0000
*************** write_contents (abfd, sec, xxx)
*** 1135,1141 ****
       PTR xxx ATTRIBUTE_UNUSED;
  {
    segment_info_type *seginfo = seg_info (sec);
!   unsigned long offset = 0;
    fragS *f;
  
    /* Write out the frags.  */
--- 1135,1141 ----
       PTR xxx ATTRIBUTE_UNUSED;
  {
    segment_info_type *seginfo = seg_info (sec);
!   addressT offset = 0;
    fragS *f;
  
    /* Write out the frags.  */
*************** write_contents (abfd, sec, xxx)
*** 1148,1156 ****
         f = f->fr_next)
      {
        int x;
!       unsigned long fill_size;
        char *fill_literal;
!       long count;
  
        assert (f->fr_type == rs_fill);
        if (f->fr_fix)
--- 1148,1156 ----
         f = f->fr_next)
      {
        int x;
!       addressT fill_size;
        char *fill_literal;
!       offsetT count;
  
        assert (f->fr_type == rs_fill);
        if (f->fr_fix)
*************** relax_and_size_all_segments ()
*** 1310,1316 ****
  #ifdef OBJ_BOUT
    /* See above comments on b.out data section address.  */
    {
!     long bss_vma;
      if (data_last_frag == 0)
        bss_vma = H_GET_TEXT_SIZE (&headers);
      else
--- 1310,1316 ----
  #ifdef OBJ_BOUT
    /* See above comments on b.out data section address.  */
    {
!     addressT bss_vma;
      if (data_last_frag == 0)
        bss_vma = H_GET_TEXT_SIZE (&headers);
      else
*************** relax_frag (segment, fragP, stretch)
*** 2070,2076 ****
    const relax_typeS *start_type;
    relax_substateT next_state;
    relax_substateT this_state;
!   long growth;
    offsetT aim;
    addressT target;
    addressT address;
--- 2070,2076 ----
    const relax_typeS *start_type;
    relax_substateT next_state;
    relax_substateT this_state;
!   offsetT growth;
    offsetT aim;
    addressT target;
    addressT address;
*************** relax_segment (segment_frag_root, segmen
*** 2293,2299 ****
  
    /* Do relax().  */
    {
!     long stretch;	/* May be any size, 0 or negative.  */
      /* Cumulative number of addresses we have relaxed this pass.
         We may have relaxed more than one address.  */
      int stretched;	/* Have we stretched on this pass?  */
--- 2293,2299 ----
  
    /* Do relax().  */
    {
!     offsetT stretch;	/* May be any size, 0 or negative.  */
      /* Cumulative number of addresses we have relaxed this pass.
         We may have relaxed more than one address.  */
      int stretched;	/* Have we stretched on this pass?  */
*************** relax_segment (segment_frag_root, segmen
*** 2308,2314 ****
  
  	for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
  	  {
! 	    long growth = 0;
  	    addressT was_address;
  	    offsetT offset;
  	    symbolS *symbolP;
--- 2308,2314 ----
  
  	for (fragP = segment_frag_root; fragP; fragP = fragP->fr_next)
  	  {
! 	    offsetT growth = 0;
  	    addressT was_address;
  	    offsetT offset;
  	    symbolS *symbolP;
*************** relax_segment (segment_frag_root, segmen
*** 2443,2449 ****
  			 cannot have fewer than 0 chars.  That is, we can't
  			 .org backwards.  */
  		      as_bad_where (fragP->fr_file, fragP->fr_line,
! 				    _("attempt to .org backwards"));
  
  		      /* We've issued an error message.  Change the
                           frag to avoid cascading errors.  */
--- 2443,2449 ----
  			 cannot have fewer than 0 chars.  That is, we can't
  			 .org backwards.  */
  		      as_bad_where (fragP->fr_file, fragP->fr_line,
! 				    _("attempt to move .org backwards"));
  
  		      /* We've issued an error message.  Change the
                           frag to avoid cascading errors.  */
*************** relax_segment (segment_frag_root, segmen
*** 2502,2508 ****
  	      case rs_leb128:
  		{
  		  valueT value;
! 		  int size;
  
  		  value = resolve_symbol_value (fragP->fr_symbol);
  		  size = sizeof_leb128 (value, fragP->fr_subtype);
--- 2502,2508 ----
  	      case rs_leb128:
  		{
  		  valueT value;
! 		  offsetT size;
  
  		  value = resolve_symbol_value (fragP->fr_symbol);
  		  size = sizeof_leb128 (value, fragP->fr_subtype);


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