[PATCH v2] x86/Intel: avoid infinite recursion in i386_intel_simplify_symbol() (again)
Jan Beulich
jbeulich@suse.com
Fri May 15 13:03:32 GMT 2026
PR gas/30308
The same problem has appeared again due to insufficient use of the
"resolving" property (respective helpers originally introduced for this
PR) in 22f8905d9f38 ("x86/Intel: don't modify equates' expressions").
Also put in place a testcase, so this (hopefully) won't regress again.
---
v2: Restrict loop continuation further. Better and wider testcase.
--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -383,6 +383,8 @@ i386_intel_simplify_register (expression
static symbolS *
i386_intel_simplify_symbol (symbolS *sym, bool in_equate)
{
+ symbolS *orig = NULL;
+
if (symbol_resolving_p (sym))
return sym;
@@ -396,7 +398,9 @@ i386_intel_simplify_symbol (symbolS *sym
if (symbol_on_chain(sym, symbol_rootP, symbol_lastP))
{
in_equate = true;
+ orig = sym;
sym = symbol_clone (sym, 0);
+ symbol_mark_resolving (orig);
}
else if (in_equate)
{
@@ -405,6 +409,11 @@ i386_intel_simplify_symbol (symbolS *sym
if (e->X_op == O_symbol && !e->X_add_number)
{
sym = e->X_add_symbol;
+ if (symbol_resolving_p (sym))
+ return sym;
+ seg = S_GET_SEGMENT (sym);
+ if (seg != expr_section && seg != reg_section)
+ return sym;
continue;
}
sym = make_expr_symbol (e);
@@ -419,6 +428,9 @@ i386_intel_simplify_symbol (symbolS *sym
S_SET_SEGMENT (sym, absolute_section);
symbol_clear_resolving (sym);
+ if (orig)
+ symbol_clear_resolving (orig);
+
return ret ? sym : NULL;
}
--- a/gas/testsuite/gas/i386/i386.exp
+++ b/gas/testsuite/gas/i386/i386.exp
@@ -63,6 +63,7 @@ if [gas_32_check] then {
run_dump_test "opcode-suffix"
run_dump_test "intel"
run_dump_test "intel-intel"
+ run_list_test "intel-equ-loop"
run_dump_test "intel16"
run_list_test "intelbad" ""
run_dump_test "intelok"
--- /dev/null
+++ b/gas/testsuite/gas/i386/intel-equ-loop.l
@@ -0,0 +1,8 @@
+.*: Assembler messages:
+.*: Error: symbol definition loop .*
+.*: Error: can't resolve .*
+.*: Error: symbol definition loop .*
+.*: Error: can't resolve .*
+.*: Error: symbol definition loop .*
+.*: Error: can't resolve .*
+#pass
--- /dev/null
+++ b/gas/testsuite/gas/i386/intel-equ-loop.s
@@ -0,0 +1,16 @@
+ .intel_syntax noprefix
+
+ a = a
+ mov eax, [a]
+
+ b = c
+ c = b
+ mov eax, [b]
+ mov eax, [c]
+
+ d = e
+ e = d
+ x = d
+ d = 1
+ e = 2
+ mov eax, [x]
More information about the Binutils
mailing list