]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas: consolidate . latching
authorJan Beulich <jbeulich@suse.com>
Fri, 10 Jan 2025 07:43:02 +0000 (08:43 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 10 Jan 2025 07:43:02 +0000 (08:43 +0100)
... by purging dot_{frag,value}. Right now these two and dot_symbol are
updated independently, which can't be quite right. Centralize .-related
information in dot_symbol, updating it also where previously
dot_{frag,value} were updated. Since S_GET_VALUE() can't be used to
retrieve what used to be dot_value, introduce a new helper to fetch both
frag and offset.

gas/config/tc-ppc.c
gas/expr.c
gas/read.c
gas/symbols.c
gas/symbols.h
gas/write.c
gas/write.h

index d1de57e882c25e57e39d5ae5b7211c1445a5311e..9c3adb39950404235654e1dc956d3c768e36dfc8 100644 (file)
@@ -4082,12 +4082,14 @@ md_assemble (char *str)
         a label attached to the instruction.  By "attached" we mean
         on the same source line as the instruction and without any
         intervening semicolons.  */
-      dot_value = frag_now_fix ();
-      dot_frag = frag_now;
+      symbol_set_value_now (&dot_symbol);
       for (l = insn_labels; l != NULL; l = l->next)
        {
-         symbol_set_frag (l->label, dot_frag);
-         S_SET_VALUE (l->label, dot_value);
+         addressT value;
+
+         symbol_set_frag (l->label,
+                          symbol_get_frag_and_value (&dot_symbol, &value));
+         S_SET_VALUE (l->label, value);
        }
     }
 
index ccd89253ac1cb05fe811965c9751f13f495de40e..665131989118abdb5e53f2a1a1a1f99e65421af3 100644 (file)
@@ -1849,10 +1849,7 @@ expr (int rankarg,               /* Larger # is higher rank.  */
 
   /* Save the value of dot for the fixup code.  */
   if (rank == 0)
-    {
-      dot_value = frag_now_fix ();
-      dot_frag = frag_now;
-    }
+    symbol_set_value_now (&dot_symbol);
 
   retval = operand (resultP, mode);
 
index c51536f44f91e4ce26e7ebe5c8b9f628e2971e4b..03c19ee0824350d036472cd6499ad2ac734ac955 100644 (file)
@@ -4483,8 +4483,7 @@ emit_expr_with_reloc (expressionS *exp,
     return;
 
   frag_grow (nbytes);
-  dot_value = frag_now_fix ();
-  dot_frag = frag_now;
+  symbol_set_value_now (&dot_symbol);
 
 #ifndef NO_LISTING
 #ifdef OBJ_ELF
index e6f3d85a75d31adbdad8fbab0e4c3cf095eab172..37a1e2b82153c7dd397b1c283094ba21bfd0b533 100644 (file)
@@ -2814,6 +2814,23 @@ symbol_get_frag (const symbolS *s)
   return s->frag;
 }
 
+/* Return the frag of a symbol and the symbol's offset into that frag.  */
+
+fragS *symbol_get_frag_and_value (const symbolS *s, addressT *value)
+{
+  if (s->flags.local_symbol)
+    {
+      const struct local_symbol *locsym = (const struct local_symbol *) s;
+
+      *value = locsym->value;
+      return locsym->frag;
+    }
+
+  gas_assert (s->x->value.X_op == O_constant);
+  *value = s->x->value.X_add_number;
+  return s->frag;
+}
+
 /* Mark a symbol as having been used.  */
 
 void
index df6acfffc4865b3053bfa27f15863b118854356d..465a1ab17c2892962c985ea99907b2c4e9529d2f 100644 (file)
@@ -189,6 +189,7 @@ extern offsetT *symbol_X_add_number (const symbolS *);
 extern void symbol_set_value_now (symbolS *);
 extern void symbol_set_frag (symbolS *, fragS *);
 extern fragS *symbol_get_frag (const symbolS *);
+extern fragS *symbol_get_frag_and_value (const symbolS *, addressT *);
 extern void symbol_mark_used (symbolS *);
 extern void symbol_clear_used (symbolS *);
 extern int symbol_used_p (const symbolS *);
index c52a16947e51b8792050bae5d1cbc1b24c6063f6..e823160396133835b9de12166a780f19e4695467 100644 (file)
@@ -110,12 +110,6 @@ int symbol_table_frozen;
 
 symbolS *abs_section_sym;
 
-/* Remember the value of dot when parsing expressions.  */
-addressT dot_value;
-
-/* The frag that dot_value is based from.  */
-fragS *dot_frag;
-
 /* Relocs generated by ".reloc" pseudo.  */
 struct reloc_list* reloc_list;
 
@@ -162,8 +156,8 @@ fix_new_internal (fragS *frag,              /* Which frag?  */
   fixP->fx_addsy = add_symbol;
   fixP->fx_subsy = sub_symbol;
   fixP->fx_offset = offset;
-  fixP->fx_dot_value = dot_value;
-  fixP->fx_dot_frag = dot_frag;
+  fixP->fx_dot_frag = symbol_get_frag_and_value (&dot_symbol,
+                                                &fixP->fx_dot_value);
   fixP->fx_pcrel = pcrel;
   fixP->fx_r_type = r_type;
   fixP->fx_pcrel_adjust = 0;
index 3cd8250456867ec52f3fd5e50f1c6b3db5ec8621..eb6ac642a104fc53430b0843d57acb2c0675907e 100644 (file)
@@ -170,8 +170,6 @@ struct reloc_list
 
 extern int finalize_syms;
 extern symbolS *abs_section_sym;
-extern addressT dot_value;
-extern fragS *dot_frag;
 extern struct reloc_list* reloc_list;
 
 extern void append (char **, char *, unsigned long);