From 13bc2a41289071dad06f27330e30ec00b6122ba2 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sun, 24 May 2026 08:04:26 +0800
Subject: [PATCH] x86: Pass "%s" to i386_dis_printf as the format string
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit aeced13ee0cd570d78cb37ab1f9bba840958515a
Author: Jan Beulich <jbeulich@suse.com>
Date:   Fri May 22 08:49:12 2026 +0200

    x86/disasm: rework comment handling

caused:

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I../../opcodes -I. -I../../opcodes -I../bfd -I../../opcodes/../include -I../../opcodes/../bfd -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -mtls-dialect=gnu -flto=8 -std=gnu11 -fprofile-generate -flto=jobserver -ffat-lto-objects -MT i386-dis.lo -MD -MP -MF .deps/i386-dis.Tpo -c ../../opcodes/i386-dis.c  -fPIC -DPIC -o .libs/i386-dis.o
../../opcodes/i386-dis.c: In function ‘print_insn’:
../../opcodes/i386-dis.c:10378:9: error: format not a string literal and no format arguments [-Werror=format-security]
10378 |         i386_dis_printf (info, dis_style_comment_start, sep);
      |         ^~~~~~~~~~~~~~~
../../opcodes/i386-dis.c:10387:9: error: format not a string literal and no format arguments [-Werror=format-security]
10387 |         i386_dis_printf (info, dis_style_comment_start, sep);
      |         ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[4]: *** [Makefile:1076: i386-dis.lo] Error 1

Since i386_dis_printf is declared as

static void ATTRIBUTE_PRINTF_3 i386_dis_printf (const disassemble_info *,
                                                enum disassembler_style,
                                                const char *, ...);

the 3rd argument should be a string literal as the format string.  Pass
"%s" to i386_dis_printf as the format string to fix the regression.

	PR binutils/34168
	* i386-dis.c (print_insn): Pass "%s" to i386_dis_printf as the
	format string.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
 opcodes/i386-dis.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c
index 1faf1fa7785..3a5db14a1dc 100644
--- a/opcodes/i386-dis.c
+++ b/opcodes/i386-dis.c
@@ -10375,7 +10375,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
   for (i = 0; i < MAX_OPERANDS; i++)
     if (ins.op_index[i] != -1 && ins.op_riprel[i])
       {
-	i386_dis_printf (info, dis_style_comment_start, sep);
+	i386_dis_printf (info, dis_style_comment_start, "%s", sep);
 	sep = ", ";
 	(*info->print_address_func)
 	  ((bfd_vma)(ins.start_pc + (ins.codep - ins.start_codep)
@@ -10384,7 +10384,7 @@ print_insn (bfd_vma pc, disassemble_info *info, int intel_syntax)
       }
     else if (*ins.cm_out[i])
       {
-	i386_dis_printf (info, dis_style_comment_start, sep);
+	i386_dis_printf (info, dis_style_comment_start, "%s", sep);
 	sep = ", ";
 	i386_dis_printf (info, dis_style_symbol, "%s", ins.cm_out[i]);
       }
-- 
2.54.0

