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]

[PATCH] use symbol octet offsets


This is an extension of the previous tic54x patch, as requested by
amodra.  I've not made any changes to the broken_dot_word section of
relax_segment, since it's not clear at this point whether the fields
within struct broken_word should refer to byte (address) or octet
offsets.

When symbol values are accessed, the octet offset into its section
should be used when dealing with abstract chunks of octet-based data.
This mostly has to do with frag addresses, which are currently octet
offsets rather than target addresses.


2001-11-15  Timothy Wall  <twall@oculustech.com>

	* write.c: Make sure symbol references use octet offsets into the
	section instead of the symbol's address.  In most cases these are
	the same, but will differ where target bytes are not a single
	octet.  
 
Index: write.c
===================================================================
RCS file: /cvs/src/src/gas/write.c,v
retrieving revision 1.48
diff -c -d -p -b -w -r1.48 write.c
*** write.c	2001/11/13 14:22:40	1.48
--- write.c	2001/11/15 16:46:41
*************** cvt_frag_to_fill (headersP, sec, fragP)
*** 536,542 ****
  
      case rs_leb128:
        {
! 	valueT value = S_GET_VALUE (fragP->fr_symbol);
  	int size;
  
  	size = output_leb128 (fragP->fr_literal + fragP->fr_fix, value,
--- 536,544 ----
  
      case rs_leb128:
        {
!         /* Use the symbol's octet offset into the section rather than its
!            address.  */
! 	valueT value = S_GET_VALUE (fragP->fr_symbol) * OCTETS_PER_BYTE;
  	int size;
  
  	size = output_leb128 (fragP->fr_literal + fragP->fr_fix, value,
*************** adjust_reloc_syms (abfd, sec, xxx)
*** 909,916 ****
  
  	   We refetch the segment when calling section_symbol, rather
  	   than using symsec, because S_GET_VALUE may wind up changing
! 	   the section when it calls resolve_symbol_value.  */
! 	fixp->fx_offset += S_GET_VALUE (sym);
  	fixp->fx_addsy = section_symbol (S_GET_SEGMENT (sym));
  	symbol_mark_used_in_reloc (fixp->fx_addsy);
  #ifdef DEBUG5
--- 911,921 ----
  
  	   We refetch the segment when calling section_symbol, rather
  	   than using symsec, because S_GET_VALUE may wind up changing
! 	   the section when it calls resolve_symbol_value.  
! 
!            Use the symbol's octet offset into the section, not its 
!            address.  */ 
! 	fixp->fx_offset += S_GET_VALUE (sym) * OCTETS_PER_BYTE;
  	fixp->fx_addsy = section_symbol (S_GET_SEGMENT (sym));
  	symbol_mark_used_in_reloc (fixp->fx_addsy);
  #ifdef DEBUG5
*************** relax_frag (segment, fragP, stretch)
*** 2105,2111 ****
  #endif
        know (!(S_GET_SEGMENT (symbolP) == absolute_section)
  	    || sym_frag == &zero_address_frag);
!       target += S_GET_VALUE (symbolP);
  
        /* If frag has yet to be reached on this pass,
  	 assume it will move by STRETCH just as we did.
--- 2110,2120 ----
  #endif
        know (!(S_GET_SEGMENT (symbolP) == absolute_section)
  	    || sym_frag == &zero_address_frag);
!       know (S_GET_SECTION (symbolP)->vma == 0);
!       /* Convert from the symbol address to an octet offset into the section,
!          which is what frags use.  Since the section's VMA is zero at this
!          point, we can omit subtracting it from the symbol's value.  */
!       target += S_GET_VALUE (symbolP) * OCTETS_PER_BYTE;
  
        /* If frag has yet to be reached on this pass,
  	 assume it will move by STRETCH just as we did.
*************** relax_segment (segment_frag_root, segmen
*** 2469,2475 ****
  		  {
  		    offsetT amount;
  
! 		    amount = S_GET_VALUE (symbolP);
  		    if (S_GET_SEGMENT (symbolP) != absolute_section
  			|| S_IS_COMMON (symbolP)
  			|| ! S_IS_DEFINED (symbolP))
--- 2478,2486 ----
  		  {
  		    offsetT amount;
  
!                     /* Use the symbol's octet offset into its section, not its
!                        address.  */
! 		    amount = S_GET_VALUE (symbolP) * OCTETS_PER_BYTE;
  		    if (S_GET_SEGMENT (symbolP) != absolute_section
  			|| S_IS_COMMON (symbolP)
  			|| ! S_IS_DEFINED (symbolP))
*************** fixup_segment (fixP, this_segment_type)
*** 2620,2626 ****
  	  && symbol_mri_common_p (add_symbolP))
  	{
  	  know (add_symbolP->sy_value.X_op == O_symbol);
! 	  add_number += S_GET_VALUE (add_symbolP);
  	  fixP->fx_offset = add_number;
  	  add_symbolP = fixP->fx_addsy =
  	    symbol_get_value_expression (add_symbolP)->X_add_symbol;
--- 2631,2639 ----
  	  && symbol_mri_common_p (add_symbolP))
  	{
  	  know (add_symbolP->sy_value.X_op == O_symbol);
!           /* Use the symbol's octet offset into its section, not its 
!              address.  */
! 	  add_number += S_GET_VALUE (add_symbolP) * OCTETS_PER_BYTE;
  	  fixP->fx_offset = add_number;
  	  add_symbolP = fixP->fx_addsy =
  	    symbol_get_value_expression (add_symbolP)->X_add_symbol;
*************** fixup_segment (fixP, this_segment_type)
*** 2636,2642 ****
  	    {
  	      if (add_symbolP != NULL)
  		{
! 		  add_number += S_GET_VALUE (add_symbolP);
  		  add_symbolP = NULL;
  		  fixP->fx_addsy = NULL;
  		}
--- 2649,2657 ----
  	    {
  	      if (add_symbolP != NULL)
  		{
!                   /* Use the symbol's octet offset into its section, not its 
!                      address.  */
! 		  add_number += S_GET_VALUE (add_symbolP) * OCTETS_PER_BYTE;
  		  add_symbolP = NULL;
  		  fixP->fx_addsy = NULL;
  		}
*************** fixup_segment (fixP, this_segment_type)
*** 2644,2650 ****
  	      /* It's just -sym.  */
  	      if (S_GET_SEGMENT (sub_symbolP) == absolute_section)
  		{
! 		  add_number -= S_GET_VALUE (sub_symbolP);
  		  fixP->fx_subsy = NULL;
  		}
  	      else if (pcrel
--- 2659,2667 ----
  	      /* It's just -sym.  */
  	      if (S_GET_SEGMENT (sub_symbolP) == absolute_section)
  		{
!                   /* Use the symbol's octet offset into its section, not its 
!                      address.  */
! 		  add_number -= S_GET_VALUE (sub_symbolP) * OCTETS_PER_BYTE;
  		  fixP->fx_subsy = NULL;
  		}
  	      else if (pcrel
*************** fixup_segment (fixP, this_segment_type)
*** 2673,2679 ****
  			      _("callj to difference of two symbols"));
  #endif /* TC_I960  */
  	      add_number += (S_GET_VALUE (add_symbolP)
! 			     - S_GET_VALUE (sub_symbolP));
  	      if (1
  #ifdef TC_M68K
  		  /* See the comment below about 68k weirdness.  */
--- 2690,2696 ----
  			      _("callj to difference of two symbols"));
  #endif /* TC_I960  */
  	      add_number += (S_GET_VALUE (add_symbolP)
!                              - S_GET_VALUE (sub_symbolP)) * OCTETS_PER_BYTE;
  	      if (1
  #ifdef TC_M68K
  		  /* See the comment below about 68k weirdness.  */
*************** fixup_segment (fixP, this_segment_type)
*** 2702,2708 ****
  		      && (S_GET_SEGMENT (sub_symbolP) == absolute_section)));
  
  	      if ((S_GET_SEGMENT (sub_symbolP) == absolute_section))
! 		add_number -= S_GET_VALUE (sub_symbolP);
  
  #ifdef DIFF_EXPR_OK
  	      else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type)
--- 2719,2725 ----
  		      && (S_GET_SEGMENT (sub_symbolP) == absolute_section)));
  
  	      if ((S_GET_SEGMENT (sub_symbolP) == absolute_section))
! 		add_number -= S_GET_VALUE (sub_symbolP) * OCTETS_PER_BYTE;
  
  #ifdef DIFF_EXPR_OK
  	      else if (S_GET_SEGMENT (sub_symbolP) == this_segment_type)
*************** fixup_segment (fixP, this_segment_type)
*** 2724,2730 ****
  		      fixP->fx_pcrel = 1;
  		    }
  
! 		  add_number -= S_GET_VALUE (sub_symbolP);
  		  sub_symbolP = 0;
  		  fixP->fx_subsy = 0;
  		}
--- 2741,2747 ----
  		      fixP->fx_pcrel = 1;
  		    }
  
! 		  add_number -= S_GET_VALUE (sub_symbolP) * OCTETS_PER_BYTE;
  		  sub_symbolP = 0;
  		  fixP->fx_subsy = 0;
  		}
*************** fixup_segment (fixP, this_segment_type)
*** 2777,2783 ****
  	      reloc_callj (fixP);
  #endif /* TC_I960  */
  
! 	      add_number += S_GET_VALUE (add_symbolP);
  	      add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment_type);
  	      /* Lie.  Don't want further pcrel processing.  */
  	      pcrel = 0;
--- 2794,2800 ----
  	      reloc_callj (fixP);
  #endif /* TC_I960  */
  
! 	      add_number += S_GET_VALUE (add_symbolP) * OCTETS_PER_BYTE;
  	      add_number -= MD_PCREL_FROM_SECTION (fixP, this_segment_type);
  	      /* Lie.  Don't want further pcrel processing.  */
  	      pcrel = 0;
*************** fixup_segment (fixP, this_segment_type)
*** 2800,2806 ****
  		  /* See comment about reloc_callj() above.  */
  		  reloc_callj (fixP);
  #endif /* TC_I960  */
! 		  add_number += S_GET_VALUE (add_symbolP);
  
  		  /* Let the target machine make the final determination
  		     as to whether or not a relocation will be needed to
--- 2817,2823 ----
  		  /* See comment about reloc_callj() above.  */
  		  reloc_callj (fixP);
  #endif /* TC_I960  */
! 		  add_number += S_GET_VALUE (add_symbolP) * OCTETS_PER_BYTE;
  
  		  /* Let the target machine make the final determination
  		     as to whether or not a relocation will be needed to
*************** fixup_segment (fixP, this_segment_type)
*** 2839,2845 ****
  #ifdef OBJ_COFF
  #ifdef TE_I386AIX
  		  if (S_IS_COMMON (add_symbolP))
! 		    add_number += S_GET_VALUE (add_symbolP);
  #endif /* TE_I386AIX  */
  #endif /* OBJ_COFF  */
  		  ++seg_reloc_count;
--- 2856,2862 ----
  #ifdef OBJ_COFF
  #ifdef TE_I386AIX
  		  if (S_IS_COMMON (add_symbolP))
! 		    add_number += S_GET_VALUE (add_symbolP) * OCTETS_PER_BYTE;
  #endif /* TE_I386AIX  */
  #endif /* OBJ_COFF  */
  		  ++seg_reloc_count;
*************** fixup_segment (fixP, this_segment_type)
*** 2848,2854 ****
  		{
  		  seg_reloc_count++;
  		  if (TC_FIX_ADJUSTABLE (fixP))
! 		    add_number += S_GET_VALUE (add_symbolP);
  		}
  	    }
  	}
--- 2865,2871 ----
  		{
  		  seg_reloc_count++;
  		  if (TC_FIX_ADJUSTABLE (fixP))
! 		    add_number += S_GET_VALUE (add_symbolP) * OCTETS_PER_BYTE;
  		}
  	    }
  	}

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