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]

local sym evaluation


resolve_symbol_value was dividing an already resolved local symbol
value by OCTETS_PER_BYTE.  This is incorrect since the value stored
has already been divided by OCTETS_PER_BYTE.  In fact, since
local_symbol_make, S_SET_VALUE, and resolve_symbol_value all store
values rather than address offsets, I decided to change the name of
lsy_offset to reflect reality.

	* struc-symbol.h (struct local_symbol): Rename lsy_offset to
	lsy_value.  Correct typos in comments.
	* symbols.c (local_symbol_make): Update for name change.
	(local_symbol_convert): Likewise.
	(colon): Likewise.
	(S_GET_VALUE): Likewise.
	(S_SET_VALUE): Likewise.
	(print_symbol_value_1): Likewise.
	(resolve_symbol_value): Likewise.  Don't divide local sym values
	by OCTETS_PER_BYTE twice.

-- 
Alan Modra

Index: gas/struc-symbol.h
===================================================================
RCS file: /cvs/src/src/gas/struc-symbol.h,v
retrieving revision 1.7
diff -u -p -r1.7 struc-symbol.h
--- struc-symbol.h	2001/04/14 06:57:28	1.7
+++ struc-symbol.h	2001/07/05 05:38:05
@@ -122,14 +122,14 @@ struct local_symbol
 
   /* The symbol section.  This also serves as a flag.  If this is
      reg_section, then this symbol has been converted into a regular
-     symbol, and sy_sym points to it.  */
+     symbol, and lsy_sym points to it.  */
   segT lsy_section;
 
   /* The symbol name.  */
   const char *lsy_name;
 
   /* The symbol frag or the real symbol, depending upon the value in
-     sy_section.  If the symbol has been fully resolved, lsy_frag is
+     lsy_section.  If the symbol has been fully resolved, lsy_frag is
      set to NULL.  */
   union
   {
@@ -137,8 +137,8 @@ struct local_symbol
     symbolS *lsy_sym;
   } u;
 
-  /* The offset within the frag.  */
-  valueT lsy_offset;
+  /* The value of the symbol.  */
+  valueT lsy_value;
 
 #ifdef TC_LOCAL_SYMFIELD_TYPE
   TC_LOCAL_SYMFIELD_TYPE lsy_tc;
Index: gas/symbols.c
===================================================================
RCS file: /cvs/src/src/gas/symbols.c,v
retrieving revision 1.25
diff -u -p -r1.25 symbols.c
--- symbols.c	2001/06/05 08:29:59	1.25
+++ symbols.c	2001/07/05 05:38:07
@@ -206,10 +206,10 @@ static unsigned long local_symbol_conver
 /* Create a local symbol and insert it into the local hash table.  */
 
 static struct local_symbol *
-local_symbol_make (name, section, offset, frag)
+local_symbol_make (name, section, value, frag)
      const char *name;
      segT section;
-     valueT offset;
+     valueT value;
      fragS *frag;
 {
   char *name_copy;
@@ -224,7 +224,7 @@ local_symbol_make (name, section, offset
   ret->lsy_name = name_copy;
   ret->lsy_section = section;
   local_symbol_set_frag (ret, frag);
-  ret->lsy_offset = offset;
+  ret->lsy_value = value;
 
   hash_jam (local_hash, name_copy, (PTR) ret);
 
@@ -246,7 +246,7 @@ local_symbol_convert (locsym)
 
   ++local_symbol_conversion_count;
 
-  ret = symbol_new (locsym->lsy_name, locsym->lsy_section, locsym->lsy_offset,
+  ret = symbol_new (locsym->lsy_name, locsym->lsy_section, locsym->lsy_value,
 		    local_symbol_get_frag (locsym));
 
   if (local_symbol_resolved_p (locsym))
@@ -357,7 +357,7 @@ colon (sym_name)		/* Just seen "x:" - ra
 	  if (locsym->lsy_section != undefined_section
 	      && (local_symbol_get_frag (locsym) != frag_now
 		  || locsym->lsy_section != now_seg
-		  || locsym->lsy_offset != frag_now_fix ()))
+		  || locsym->lsy_value != frag_now_fix ()))
 	    {
 	      as_bad (_("Symbol %s already defined."), sym_name);
 	      return symbolP;
@@ -365,7 +365,7 @@ colon (sym_name)		/* Just seen "x:" - ra
 
 	  locsym->lsy_section = now_seg;
 	  local_symbol_set_frag (locsym, frag_now);
-	  locsym->lsy_offset = frag_now_fix ();
+	  locsym->lsy_value = frag_now_fix ();
 #endif
 	}
       else if (!S_IS_DEFINED (symbolP) || S_IS_COMMON (symbolP))
@@ -843,15 +843,15 @@ resolve_symbol_value (symp)
     {
       struct local_symbol *locsym = (struct local_symbol *) symp;
 
+      final_val = locsym->lsy_value;
       if (local_symbol_resolved_p (locsym))
-	return locsym->lsy_offset / bfd_octets_per_byte (stdoutput);
+	return final_val;
 
-      final_val = (local_symbol_get_frag (locsym)->fr_address
-		   + locsym->lsy_offset) / bfd_octets_per_byte (stdoutput);
+      final_val += local_symbol_get_frag (locsym)->fr_address / OCTETS_PER_BYTE;
 
       if (finalize_syms)
 	{
-	  locsym->lsy_offset = final_val;
+	  locsym->lsy_value = final_val;
 	  local_symbol_mark_resolved (locsym);
 	}
 
@@ -1574,7 +1574,7 @@ S_GET_VALUE (s)
 {
 #ifdef BFD_ASSEMBLER
   if (LOCAL_SYMBOL_CHECK (s))
-    return ((struct local_symbol *) s)->lsy_offset;
+    return ((struct local_symbol *) s)->lsy_value;
 #endif
 
   if (!s->sy_resolved && s->sy_value.X_op != O_constant)
@@ -1613,7 +1613,7 @@ S_SET_VALUE (s, val)
 #ifdef BFD_ASSEMBLER
   if (LOCAL_SYMBOL_CHECK (s))
     {
-      ((struct local_symbol *) s)->lsy_offset = val;
+      ((struct local_symbol *) s)->lsy_value = val;
       return;
     }
 #endif
@@ -2341,7 +2341,7 @@ print_symbol_value_1 (file, sym)
 #ifdef BFD_ASSEMBLER
       if (LOCAL_SYMBOL_CHECK (sym))
 	fprintf (file, "constant %lx",
-		 (long) ((struct local_symbol *) sym)->lsy_offset);
+		 (long) ((struct local_symbol *) sym)->lsy_value);
       else
 #endif
 	print_expr_1 (file, &sym->sy_value);


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