gprofng format mismatch on 32-bit host

Message ID adMJBOx4uQ62SRAv@squeak.grove.modra.org
State New
Headers
Series gprofng format mismatch on 32-bit host |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Alan Modra April 6, 2026, 1:14 a.m. UTC
  On a 32-bit host without --enable-64-bit-bfd

gp-gmon.cc:531:42: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘bfd_size_type’ {aka ‘unsigned int’} [-Wformat=]

On a 32-bit-host with --enable-64-bit-bfd the underlying type will be
unsigned long long.

	* src/gp-gmon.cc (gen_gmon_map): Use %llu to print msize, and cast.
  

Patch

diff --git a/gprofng/src/gp-gmon.cc b/gprofng/src/gp-gmon.cc
index d3b4a67f51c..f8a8adb7fc9 100644
--- a/gprofng/src/gp-gmon.cc
+++ b/gprofng/src/gp-gmon.cc
@@ -528,12 +528,12 @@  gen_gmon_map (char *name)
   msize = (msize + page_size - 1) & mpage;
 
   fprintf (mapx, "<event kind=\"map\" object=\"segment\" tstamp=\"%u.%09u\" "
-	   "vaddr=\"0x%016llX\" size=\"%lu\" pagesz=\"%d\" foffset=\"%c0x%08llX\" "
+	   "vaddr=\"0x%016llX\" size=\"%llu\" pagesz=\"%d\" foffset=\"%c0x%08llX\" "
 	   "modes=\"0x%03X\" chksum=\"0x%0X\" name=\"%s\"/>\n",
 	   (unsigned) (timestamp / NANOSEC),
 	   (unsigned) (timestamp % NANOSEC),
-	   (long long unsigned) loadaddr, msize, (int) page_size,
-	   offset < 0 ? '-' : '+',
+	   (long long unsigned) loadaddr, (long long unsigned) msize,
+	   (int) page_size, offset < 0 ? '-' : '+',
 	   (long long unsigned) (offset < 0 ? -offset : offset),
 	   modeflags, check, name);