X86/Intel: avoid infinite recursion in i386_intel_simplify_symbol() (again)
This patch fixes an infinite recursion issue in i386_intel_simplify_symbol() and adds a testcase to prevent regressions.
Jan Beulich submits a patch to fix an infinite recursion issue in the i386_intel_simplify_symbol() function, which is related to PR gas/30308. The issue re-emerged due to insufficient use of the “resolving” property. The patch adds a testcase to prevent future regressions. He also notes a failure on COFF/PE targets when --32 is used and “noprefix” is missing.
- proposer
Proposes a patch to fix an infinite recursion issue and adds a testcase to prevent regressions.
“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.”
- contributor
Notes a failure on COFF/PE targets when `--32` is used and "noprefix" is missing.
“This fails for (at least) COFF/PE targets when as is passed --32. There looks to be a separate issue there, but ... ... "noprefix" was missing here anyway (for Intel syntax this really should be the default).”
Technical Tradeoffs
- The patch adds complexity to the symbol simplification logic.
- The added testcase increases the testsuite runtime.
In Details
This patch addresses a recursion issue in the x86-specific assembly simplification logic within GNU as. The i386_intel_simplify_symbol function is responsible for resolving symbol references in Intel syntax assembly code. The patch ensures proper handling of symbol resolution to prevent infinite loops, and adds a testcase (gas/testsuite/gas/i386/intel-equ-loop.s) to prevent future regressions. The surrounding logic deals with .intel_syntax assembly.
For Context
The GNU Assembler (gas) is a tool that translates assembly code (human-readable instructions) into machine code (binary instructions that a computer can execute). This patch fixes a bug in the assembler's handling of x86 Intel syntax, where it could get stuck in an infinite loop when simplifying symbol references. The patch prevents this from happening and adds a test case to ensure the issue doesn't reappear in the future.