From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7819) id 0DDB73858288; Wed, 15 Jun 2022 22:14:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0DDB73858288 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Sergei Trofimovich To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim: fix BFD_VMA format arguments on 32-bit hosts [PR gdb/29184] X-Act-Checkin: binutils-gdb X-Git-Author: Sergei Trofimovich X-Git-Refname: refs/heads/master X-Git-Oldrev: 9d741cbedb8a7a77bb7c99bbbc363d5af4ba62c2 X-Git-Newrev: 33b90f59f3465041a620ad4f6504a35b578cfc65 Message-Id: <20220615221435.0DDB73858288@sourceware.org> Date: Wed, 15 Jun 2022 22:14:35 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Jun 2022 22:14:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D33b90f59f346= 5041a620ad4f6504a35b578cfc65 commit 33b90f59f3465041a620ad4f6504a35b578cfc65 Author: Sergei Trofimovich Date: Sat May 21 08:53:50 2022 +0100 sim: fix BFD_VMA format arguments on 32-bit hosts [PR gdb/29184] =20 Noticed format mismatch when attempted to build gdb on i686-linux-gnu in --enable-64-bit-bfd mode: =20 sim/../../sim/cris/sim-if.c:576:28: error: format '%lx' expects argument of type 'long unsigned int= ', but argument 4 has type 'bfd_size_type' {aka 'long long unsigne= d int'} [-Werror=3Dformat=3D] 576 | sim_do_commandf (sd, "memory region 0x%" BFD_VMA_FMT = "x,0x%lx", | ^~~~~~~~~~~~~~~~~~~ 577 | interp_load_addr, interpsiz); | ~~~~~~~~~ | | | bfd_size_type {aka long long uns= igned int} =20 While at it fixed format string for time-related types. Diff: --- sim/cris/sim-if.c | 10 ++++++---- sim/m32c/syscalls.c | 4 ++-- sim/rx/syscalls.c | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sim/cris/sim-if.c b/sim/cris/sim-if.c index 5b1240f041f..d7c1005fcac 100644 --- a/sim/cris/sim-if.c +++ b/sim/cris/sim-if.c @@ -257,7 +257,8 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_= write_fn do_write) =20 if (verbose) sim_io_printf (sd, - "Loading segment at 0x%" BFD_VMA_FMT "x, size 0x%lx\n", + "Loading segment at 0x%" BFD_VMA_FMT "x, " + "size 0x%" BFD_VMA_FMT "x\n", lma, phdr[i].p_filesz); =20 if (bfd_seek (abfd, phdr[i].p_offset, SEEK_SET) !=3D 0 @@ -265,7 +266,7 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_= write_fn do_write) { sim_io_eprintf (sd, "%s: could not read segment at 0x%" BFD_VMA_FMT "x, " - "size 0x%lx\n", + "size 0x%" BFD_VMA_FMT "x\n", STATE_MY_NAME (sd), lma, phdr[i].p_filesz); free (buf); return FALSE; @@ -275,7 +276,7 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_= write_fn do_write) { sim_io_eprintf (sd, "%s: could not load segment at 0x%" BFD_VMA_FMT "x, " - "size 0x%lx\n", + "size 0x%" BFD_VMA_FMT "x\n", STATE_MY_NAME (sd), lma, phdr[i].p_filesz); free (buf); return FALSE; @@ -572,7 +573,8 @@ cris_handle_interpreter (SIM_DESC sd, struct bfd *abfd) memory area, so we go via a temporary area. Luckily, the interpreter is supposed to be small, less than 0x40000 bytes. */ - sim_do_commandf (sd, "memory region 0x%" BFD_VMA_FMT "x,0x%lx", + sim_do_commandf (sd, "memory region 0x%" BFD_VMA_FMT "x," + "0x%" BFD_VMA_FMT "x", interp_load_addr, interpsiz); =20 /* Now that memory for the interpreter is defined, load it. */ diff --git a/sim/m32c/syscalls.c b/sim/m32c/syscalls.c index 27d4e8f737f..fff4fc93314 100644 --- a/sim/m32c/syscalls.c +++ b/sim/m32c/syscalls.c @@ -299,8 +299,8 @@ m32c_syscall (int id) =20 rv =3D gettimeofday (&tv, 0); if (trace) - printf ("gettimeofday: %ld sec %ld usec to 0x%x\n", tv.tv_sec, - tv.tv_usec, tvaddr); + printf ("gettimeofday: %" PRId64 " sec %" PRId64 " usec to 0x%x\n", + (int64_t)tv.tv_sec, (int64_t)tv.tv_usec, tvaddr); mem_put_si (tvaddr, tv.tv_sec); mem_put_si (tvaddr + 4, tv.tv_usec); put_reg (r0, rv); diff --git a/sim/rx/syscalls.c b/sim/rx/syscalls.c index 285d4573da1..35ba7d9000b 100644 --- a/sim/rx/syscalls.c +++ b/sim/rx/syscalls.c @@ -270,8 +270,8 @@ rx_syscall (int id) =20 rv =3D gettimeofday (&tv, 0); if (trace) - printf ("gettimeofday: %ld sec %ld usec to 0x%x\n", tv.tv_sec, - tv.tv_usec, tvaddr); + printf ("gettimeofday: %" PRId64 " sec %" PRId64 " usec to 0x%x\n", + (int64_t)tv.tv_sec, (int64_t)tv.tv_usec, tvaddr); mem_put_si (tvaddr, tv.tv_sec); mem_put_si (tvaddr + 4, tv.tv_usec); put_reg (1, rv);