PR 30308 yet again
Alan Modra
amodra@gmail.com
Thu Jun 11 23:47:59 GMT 2026
Commit cc28c46227cd removed the symbol_resolving recursion guards in
i386_intel_simplify_symbol. The testcases we'd considered then just
involved simple equates, handled by symbol_equated_to. However, more
complex expressions can also cause unbounded recursion. This patch
restores the recursion guards.
* config/tc-i386-intel.c (i386_intel_simplify_symbol): Add
recursion guards.
* testsuite/gas/i386/intel-equ-loop.s,
* testsuite/gas/i386/intel-equ-loop.l: Extend testcase.
diff --git a/gas/config/tc-i386-intel.c b/gas/config/tc-i386-intel.c
index 77b61d426bc..21d3a333182 100644
--- a/gas/config/tc-i386-intel.c
+++ b/gas/config/tc-i386-intel.c
@@ -383,6 +383,9 @@ i386_intel_simplify_register (expressionS *e)
static symbolS *
i386_intel_simplify_symbol (symbolS *sym)
{
+ if (symbol_resolving_p (sym))
+ return sym;
+
symbolS *orig = sym;
offsetT off;
sym = symbol_equated_to (sym, &off);
@@ -405,7 +408,9 @@ i386_intel_simplify_symbol (symbolS *sym)
expressionS *e = symbol_get_value_expression (sym);
expressionS exp;
memcpy (&exp, e, sizeof exp);
+ symbol_mark_resolving (sym);
int ret = i386_intel_simplify (&exp);
+ symbol_clear_resolving (sym);
if (ret == 0)
return NULL;
diff --git a/gas/testsuite/gas/i386/intel-equ-loop.l b/gas/testsuite/gas/i386/intel-equ-loop.l
index 76ca03a43df..90dfa9623db 100644
--- a/gas/testsuite/gas/i386/intel-equ-loop.l
+++ b/gas/testsuite/gas/i386/intel-equ-loop.l
@@ -5,4 +5,6 @@
.*: Error: can't resolve .*
.*: Error: symbol definition loop .*
.*: Error: can't resolve .*
+.*: Error: symbol definition loop .*
+.*: Error: can't resolve .*
#pass
diff --git a/gas/testsuite/gas/i386/intel-equ-loop.s b/gas/testsuite/gas/i386/intel-equ-loop.s
index bb0cce8f413..02b2d3f44ff 100644
--- a/gas/testsuite/gas/i386/intel-equ-loop.s
+++ b/gas/testsuite/gas/i386/intel-equ-loop.s
@@ -14,3 +14,7 @@
d = 1
e = 2
mov eax, [x]
+
+ f = g + 1
+ g = f - 1
+ mov eax, [f]
--
Alan Modra
More information about the Binutils
mailing list