]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
bfd: Use PRIu64 to print uint64_t in elf-attrs.c
authorRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 22 Jan 2026 15:21:00 +0000 (16:21 +0100)
committerRainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Thu, 22 Jan 2026 15:21:00 +0000 (16:21 +0100)
elf-attrs.c has two more errors when built on 32-bit hosts:

In file included from bfd/elf-attrs.c:140:
bfd/elf-attrs.c: In function ‘oav2_parse_subsection’:
bfd/elf-attrs.c:2752:29: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Werror=format=]
 2752 |       _bfd_error_handler (_("%pB: error: bad subsection length (%u > max=%lu)"),

In file included from bfd/sysdep.h:165,
                 from bfd/elf-attrs.c:140:
bfd/elf-attrs.c: In function ‘_bfd_elf_parse_attributes’:
bfd/elf-attrs.c:2910:12: error: format ‘%lld’ expects argument of type ‘long long int’, but argument 4 has type ‘bfd_size_type’ {aka ‘unsigned int’} [-Werror=format=]
 2910 |         (_("%pB: error: attribute section '%pA' too big: %" PRId64),

Fixed like this.

Tested on sparc-sun-solaris2.11, i386-pc-solaris2.11, and i686-pc-linux-gnu
with --enable-64-bit-bfd.

2026-01-22  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

bfd:
* elf-attrs.c (oav2_parse_subsection): Use PRIu64 to print
uint64_t.
(_bfd_elf_parse_attributes): Use PRIu64.
Cast bfd_size_t arg to uint64_t.

bfd/elf-attrs.c

index fe85f4b4712c020b30670cb0439d4967ca64a2be..4689bedb38ecba6a1b6aa3b86b05b660642c3123 100644 (file)
@@ -2749,8 +2749,9 @@ oav2_parse_subsection (bfd *abfd,
   cursor += F_SUBSECTION_LEN;
   if (subsection_len > max_read)
     {
-      _bfd_error_handler (_("%pB: error: bad subsection length (%u > max=%lu)"),
-                         abfd, subsection_len, max_read);
+      _bfd_error_handler
+       (_("%pB: error: bad subsection length (%u > max=%" PRIu64 ")"),
+        abfd, subsection_len, max_read);
       goto error;
     }
   else if (subsection_len < F_MIN_SUBSECTION_DATA_LEN)
@@ -2907,8 +2908,8 @@ _bfd_elf_parse_attributes (bfd *abfd, Elf_Internal_Shdr * hdr)
   if (filesize != 0 && hdr->sh_size > filesize)
     {
       _bfd_error_handler
-       (_("%pB: error: attribute section '%pA' too big: %" PRId64),
-        abfd, hdr->bfd_section, hdr->sh_size);
+       (_("%pB: error: attribute section '%pA' too big: %" PRIu64),
+        abfd, hdr->bfd_section, (uint64_t) hdr->sh_size);
       bfd_set_error (bfd_error_invalid_operation);
       return;
     }