binutils Newspaper
JUNE 15, 2026
x86/disasm Proposed

x86/disasm: "Annotate immediates" flag should not be global

Makes the "annotate immediates" flag thread-local in the x86 disassembler to avoid introducing new global state.

This patch modifies the x86 disassembler to make the “annotate immediates” flag thread-local. This change avoids introducing new global state variables, as disassembly functions have been made thread-safe. The flag is moved into the instr_info struct, ensuring each thread has its own copy.

In Details

This patch refactors the x86 disassembler in opcodes/i386-dis.c to remove the global annotate_immediates variable. It moves this flag into the instr_info structure, which is local to each disassembly operation. This change is important for thread safety, as global variables can cause race conditions and unpredictable behavior in multi-threaded environments.

For Context

The disassembler converts machine code into assembly language. This patch addresses a thread-safety issue in the x86 disassembler. By making the "annotate immediates" flag thread-local, the patch ensures that multiple threads can disassemble code concurrently without interfering with each other's settings, preventing potential corruption or incorrect disassembly output.

Filed Under: x86disassemblerthread safetyglobal state