[binutils-gdb] x86/disasm: "annotate immediates" flag should not be global

Jan Beulich via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3ea80709b1d0c2d126f298a7ec3033cf9fbdb972

commit 3ea80709b1d0c2d126f298a7ec3033cf9fbdb972
Author: Jan Beulich <[email protected]>
Date:   Fri May 22 08:47:47 2026 +0200

    x86/disasm: "annotate immediates" flag should not be global
    
    With disassembly functions having been made thread-safe, no new global
    state variables should be introduced.

Diff:
---
 opcodes/i386-dis.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index f0749c1fad0..fede65a0aa7 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -41,8 +41,6 @@
 
 typedef struct instr_info instr_info;
 
-static bool annotate_immediates = false;
-
 static bool dofloat (instr_info *, int);
 static int putop (instr_info *, const char *, int);
 static void oappend_with_style (instr_info *, const char *,
@@ -277,6 +275,8 @@ struct instr_info
   char separator_char;
   char scale_char;
 
+  bool annotate_immediates;
+
   enum x86_64_isa isa64;
 };
 
@@ -9833,9 +9833,8 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
 	}
       else if (startswith (p, "suffix"))
 	priv.orig_sizeflag |= SUFFIX_ALWAYS;
-
       else if (startswith (p, "annotate"))
-	annotate_immediates = true;
+	ins.annotate_immediates = true;
 
       p = strchr (p, ',');
       if (p != NULL)
@@ -11680,7 +11679,7 @@ oappend_immediate (instr_info *ins, bfd_vma imm)
   print_operand_value (ins, imm, dis_style_immediate);
 
   /* Determine if we can display some more information about this immediate.  */
-  if (! annotate_immediates
+  if (! ins->annotate_immediates
       /* Don't bother with zero, even if there is symbol associated with it.  */
       || imm == 0
       /* For the next tests we need a BFD.  If we do not have one then do not proceed.  */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.