[binutils-gdb] bfd: Use PRIu64 to print uint64_t in elf-attrs.c
Rainer Orth
ro@sourceware.org
Thu Jan 22 15:21:29 GMT 2026
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=11f1fce44cbd0502ddf8e44bde949739ba1a87c3
commit 11f1fce44cbd0502ddf8e44bde949739ba1a87c3
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date: Thu Jan 22 16:21:00 2026 +0100
bfd: Use PRIu64 to print uint64_t in elf-attrs.c
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.
Diff:
---
bfd/elf-attrs.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/bfd/elf-attrs.c b/bfd/elf-attrs.c
index fe85f4b4712..4689bedb38e 100644
--- a/bfd/elf-attrs.c
+++ b/bfd/elf-attrs.c
@@ -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;
}
More information about the Binutils-cvs
mailing list