aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2025-01-10 08:43:02 +0100
committerJan Beulich <jbeulich@suse.com>2025-01-10 08:43:02 +0100
commit3f4bbf3c060e888299c4cc14eff52059921bed93 (patch)
treea45f9b182e531423cb4c2b127a4c6e0edaea196f
parente18fc11e47b91961ef4254323abad2a522725af2 (diff)
downloadbinutils-3f4bbf3c060e888299c4cc14eff52059921bed93.zip
binutils-3f4bbf3c060e888299c4cc14eff52059921bed93.tar.gz
binutils-3f4bbf3c060e888299c4cc14eff52059921bed93.tar.bz2
gas: consolidate . latching
... 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.
-rw-r--r--gas/config/tc-ppc.c10
-rw-r--r--gas/expr.c5
-rw-r--r--gas/read.c3
-rw-r--r--gas/symbols.c17
-rw-r--r--gas/symbols.h1
-rw-r--r--gas/write.c10
-rw-r--r--gas/write.h2
7 files changed, 28 insertions, 20 deletions
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index d1de57e..9c3adb3 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -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);
}
}
diff --git a/gas/expr.c b/gas/expr.c
index ccd8925..6651319 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -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);
diff --git a/gas/read.c b/gas/read.c
index c51536f..03c19ee 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -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
diff --git a/gas/symbols.c b/gas/symbols.c
index e6f3d85..37a1e2b 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -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
diff --git a/gas/symbols.h b/gas/symbols.h
index df6acff..465a1ab 100644
--- a/gas/symbols.h
+++ b/gas/symbols.h
@@ -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 *);
diff --git a/gas/write.c b/gas/write.c
index c52a169..e823160 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -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;
diff --git a/gas/write.h b/gas/write.h
index 3cd8250..eb6ac64 100644
--- a/gas/write.h
+++ b/gas/write.h
@@ -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);