sim: fix BFD_VMA format arguments on 32-bit hosts [PR gdb/29184]

Noticed format mismatch when attempted to build gdb on i686-linux-gnu
in --enable-64-bit-bfd mode:

    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 unsigned int'} [-Werror=format=]
      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 unsigned int}

While at it fixed format string for time-related types.
This commit is contained in:
Sergei Trofimovich
2022-05-21 08:53:50 +01:00
parent 9d741cbedb
commit 33b90f59f3
3 changed files with 10 additions and 8 deletions

View File

@@ -257,7 +257,8 @@ cris_load_elf_file (SIM_DESC sd, struct bfd *abfd, sim_write_fn do_write)
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);
if (bfd_seek (abfd, phdr[i].p_offset, SEEK_SET) != 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);
/* Now that memory for the interpreter is defined, load it. */

View File

@@ -299,8 +299,8 @@ m32c_syscall (int id)
rv = 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);

View File

@@ -270,8 +270,8 @@ rx_syscall (int id)
rv = 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);