summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2022-08-04 12:22:39 +0930
committerAlan Modra <amodra@gmail.com>2022-08-04 12:22:39 +0930
commitb82817674f46e4f08a5910719499ddc72399473f (patch)
tree079452a4c6a71ffe6493a8a818007700dad6c7e5 /bfd
parent6b9bd54c24dcf08e400e5b79a958e051ccfde30d (diff)
Don't use BFD_VMA_FMT in binutils
BFD_VMA_FMT can't be used in format strings that need to be translated, because the translation won't work when the type of bfd_vma differs from the machine used to compile .pot files. We've known about this for a long time, but patches slip through review. So just get rid of BFD_VMA_FMT, instead using the appropriate PRId64, PRIu64, PRIx64 or PRIo64 and SCN variants for scanf. The patch is mostly mechanical, the only thing requiring any thought is casts needed to preserve PRId64 output from bfd_vma values, or to preserve one of the unsigned output formats from bfd_signed_vma values.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/archive.c6
-rw-r--r--bfd/coff64-rs6000.c2
-rw-r--r--bfd/coffcode.h8
-rw-r--r--bfd/elf.c2
-rw-r--r--bfd/elf32-rx.c23
-rw-r--r--bfd/elf64-ppc.c6
-rw-r--r--bfd/elfcode.h7
-rw-r--r--bfd/elfnn-aarch64.c22
8 files changed, 40 insertions, 36 deletions
diff --git a/bfd/archive.c b/bfd/archive.c
index 9ad61adc61..19d167112b 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -192,7 +192,7 @@ _bfd_ar_sizepad (char *p, size_t n, bfd_size_type size)
char buf[21];
size_t len;
- snprintf (buf, sizeof (buf), "%-10" BFD_VMA_FMT "u", size);
+ snprintf (buf, sizeof (buf), "%-10" PRIu64, (uint64_t) size);
len = strlen (buf);
if (len > n)
{
@@ -485,7 +485,7 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag)
{
struct ar_hdr hdr;
char *hdrp = (char *) &hdr;
- bfd_size_type parsed_size;
+ uint64_t parsed_size;
struct areltdata *ared;
char *filename = NULL;
ufile_ptr filesize;
@@ -514,7 +514,7 @@ _bfd_generic_read_ar_hdr_mag (bfd *abfd, const char *mag)
errno = 0;
fmag_save = hdr.ar_fmag[0];
hdr.ar_fmag[0] = 0;
- scan = sscanf (hdr.ar_size, "%" BFD_VMA_FMT "u", &parsed_size);
+ scan = sscanf (hdr.ar_size, "%" SCNu64, &parsed_size);
hdr.ar_fmag[0] = fmag_save;
if (scan != 1)
{
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index ce1c518282..c5dc95c183 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -1595,7 +1595,7 @@ xcoff64_ppc_relocate_section (bfd *output_bfd,
default:
_bfd_error_handler
- (_("%pB: relocation (%d) at (0x%" BFD_VMA_FMT "x) has wrong"
+ (_("%pB: relocation (%d) at (0x%" PRIx64 ") has wrong"
" r_rsize (0x%x)\n"),
input_bfd, rel->r_type, rel->r_vaddr, rel->r_size);
return false;
diff --git a/bfd/coffcode.h b/bfd/coffcode.h
index 6de6ecdea3..0dc68a9a25 100644
--- a/bfd/coffcode.h
+++ b/bfd/coffcode.h
@@ -2495,15 +2495,15 @@ coff_print_aux (bfd *abfd ATTRIBUTE_UNUSED,
if (SMTYP_SMTYP (aux->u.auxent.x_csect.x_smtyp) != XTY_LD)
{
BFD_ASSERT (! aux->fix_scnlen);
- fprintf (file, "val %5" BFD_VMA_FMT "d",
- aux->u.auxent.x_csect.x_scnlen.l);
+ fprintf (file, "val %5" PRId64,
+ (int64_t) aux->u.auxent.x_csect.x_scnlen.l);
}
else
{
fprintf (file, "indx ");
if (! aux->fix_scnlen)
- fprintf (file, "%4" BFD_VMA_FMT "d",
- aux->u.auxent.x_csect.x_scnlen.l);
+ fprintf (file, "%4" PRId64,
+ (int64_t) aux->u.auxent.x_csect.x_scnlen.l);
else
fprintf (file, "%4ld",
(long) (aux->u.auxent.x_csect.x_scnlen.p - table_base));
diff --git a/bfd/elf.c b/bfd/elf.c
index 3e64cdf669..346eea39b1 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1750,7 +1750,7 @@ _bfd_elf_print_private_bfd_data (bfd *abfd, void *farg)
if (!strcmp (name, ""))
{
- sprintf (ab, "%#" BFD_VMA_FMT "x", dyn.d_tag);
+ sprintf (ab, "%#" PRIx64, (uint64_t) dyn.d_tag);
name = ab;
}
break;
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index 6df021468b..34eb88403d 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -3972,16 +3972,17 @@ rx_table_map (struct bfd_hash_entry *vent, void *vinfo)
bfd_hash_traverse (&(info->info->hash->table), rx_table_map_2, info);
- fprintf (info->mapfile, "\nRX Vector Table: %s has %d entries at 0x%08" BFD_VMA_FMT "x\n\n",
- tname, info->table_size, start_addr);
+ fprintf (info->mapfile,
+ "\nRX Vector Table: %s has %d entries at 0x%08" PRIx64 "\n\n",
+ tname, info->table_size, (uint64_t) start_addr);
if (info->table_default_entry)
- fprintf (info->mapfile, " default handler is: %s at 0x%08" BFD_VMA_FMT "x\n",
+ fprintf (info->mapfile, " default handler is: %s at 0x%08" PRIx64 "\n",
info->table_default_entry->root.string,
- info->table_default_handler);
+ (uint64_t) info->table_default_handler);
else if (info->table_default_handler != (bfd_vma)(-1))
- fprintf (info->mapfile, " default handler is at 0x%08" BFD_VMA_FMT "x\n",
- info->table_default_handler);
+ fprintf (info->mapfile, " default handler is at 0x%08" PRIx64 "\n",
+ (uint64_t) info->table_default_handler);
else
fprintf (info->mapfile, " no default handler\n");
@@ -3997,7 +3998,8 @@ rx_table_map (struct bfd_hash_entry *vent, void *vinfo)
}
need_elipses = 1;
- fprintf (info->mapfile, " 0x%08" BFD_VMA_FMT "x [%3d] ", start_addr + 4 * idx, idx);
+ fprintf (info->mapfile,
+ " 0x%08" PRIx64 " [%3d] ", (uint64_t) start_addr + 4 * idx, idx);
if (info->table_handlers[idx] == (bfd_vma) (-1))
fprintf (info->mapfile, "(no handler found)\n");
@@ -4012,12 +4014,15 @@ rx_table_map (struct bfd_hash_entry *vent, void *vinfo)
else if (info->table_entries[idx])
{
- fprintf (info->mapfile, "0x%08" BFD_VMA_FMT "x %s\n", info->table_handlers[idx], info->table_entries[idx]->root.string);
+ fprintf (info->mapfile, "0x%08" PRIx64 " %s\n",
+ (uint64_t) info->table_handlers[idx],
+ info->table_entries[idx]->root.string);
}
else
{
- fprintf (info->mapfile, "0x%08" BFD_VMA_FMT "x ???\n", info->table_handlers[idx]);
+ fprintf (info->mapfile, "0x%08" PRIx64 " ???\n",
+ (uint64_t) info->table_handlers[idx]);
}
}
if (need_elipses)
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 570b3563f2..cfcd263173 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -11670,7 +11670,7 @@ dump_stub (const char *header,
fprintf (stderr, "%s id = %u type = %s:%s:%s\n",
header, stub_entry->id, t1, t2, t3);
fprintf (stderr, "name = %s\n", stub_entry->root.string);
- fprintf (stderr, "offset = 0x%" BFD_VMA_FMT "x:", stub_entry->stub_offset);
+ fprintf (stderr, "offset = 0x%" PRIx64 ":", stub_entry->stub_offset);
for (size_t i = stub_entry->stub_offset; i < end_offset; i += 4)
{
asection *stub_sec = stub_entry->group->stub_sec;
@@ -11736,8 +11736,8 @@ ppc_build_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
fprintf (stderr, "Expected id %u, got %u\n",
htab->stub_id, stub_entry->id);
if (stub_entry->stub_offset < stub_entry->group->stub_sec->size)
- fprintf (stderr, "Expected offset >= %" BFD_VMA_FMT "x, got %"
- BFD_VMA_FMT "x\n", stub_entry->group->stub_sec->size,
+ fprintf (stderr, "Expected offset >= %" PRIx64 ", got %"
+ PRIx64 "\n", stub_entry->group->stub_sec->size,
stub_entry->stub_offset);
if (esd->sec_type == sec_stub)
dump_stub ("Previous:", esd->u.last_ent, stub_entry->stub_offset);
diff --git a/bfd/elfcode.h b/bfd/elfcode.h
index 4d4cb68164..39c84b4d0f 100644
--- a/bfd/elfcode.h
+++ b/bfd/elfcode.h
@@ -1002,9 +1002,10 @@ elf_write_relocs (bfd *abfd, asection *sec, void *data)
&& ptr->howto->bitsize > 32
&& ptr->addend - INT32_MIN > UINT32_MAX)
{
- _bfd_error_handler (_("%pB: %pA+%"BFD_VMA_FMT"x: "
- "relocation addend %"BFD_VMA_FMT"x too large"),
- abfd, sec, ptr->address, ptr->addend);
+ _bfd_error_handler (_("%pB: %pA+%" PRIx64 ": "
+ "relocation addend %" PRIx64 " too large"),
+ abfd, sec, (uint64_t) ptr->address,
+ (uint64_t) ptr->addend);
*failedp = true;
bfd_set_error (bfd_error_bad_value);
}
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index ac48a17572..7b93672c0d 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -3037,21 +3037,21 @@ elfNN_aarch64_stub_name (const asection *input_section,
len = 8 + 1 + strlen (hash->root.root.root.string) + 1 + 16 + 1;
stub_name = bfd_malloc (len);
if (stub_name != NULL)
- snprintf (stub_name, len, "%08x_%s+%" BFD_VMA_FMT "x",
+ snprintf (stub_name, len, "%08x_%s+%" PRIx64,
(unsigned int) input_section->id,
hash->root.root.root.string,
- rel->r_addend);
+ (uint64_t) rel->r_addend);
}
else
{
len = 8 + 1 + 8 + 1 + 8 + 1 + 16 + 1;
stub_name = bfd_malloc (len);
if (stub_name != NULL)
- snprintf (stub_name, len, "%08x_%x:%x+%" BFD_VMA_FMT "x",
+ snprintf (stub_name, len, "%08x_%x:%x+%" PRIx64,
(unsigned int) input_section->id,
(unsigned int) sym_sec->id,
(unsigned int) ELFNN_R_SYM (rel->r_info),
- rel->r_addend);
+ (uint64_t) rel->r_addend);
}
return stub_name;
@@ -4118,10 +4118,10 @@ _bfd_aarch64_erratum_843419_stub_name (asection *input_section,
char *stub_name = bfd_malloc (len);
if (stub_name != NULL)
- snprintf (stub_name, len, "e843419@%04x_%08x_%" BFD_VMA_FMT "x",
+ snprintf (stub_name, len, "e843419@%04x_%08x_%" PRIx64,
input_section->owner->id,
input_section->id,
- offset);
+ (uint64_t) offset);
return stub_name;
}
@@ -5358,15 +5358,13 @@ _bfd_aarch64_erratum_843419_branch_to_stub (struct bfd_hash_entry *gen_entry,
}
else
{
- char imm_buf[128];
-
- sprintf (imm_buf, "%" BFD_VMA_FMT "x", imm);
abfd = stub_entry->target_section->owner;
_bfd_error_handler
- (_("%pB: error: erratum 843419 immediate 0x%s "
- "out of range for ADR (input file too large) and "
+ (_("%pB: error: erratum 843419 immediate 0x%" PRIx64
+ " out of range for ADR (input file too large) and "
"--fix-cortex-a53-843419=adr used. Run the linker with "
- "--fix-cortex-a53-843419=full instead"), abfd, imm_buf);
+ "--fix-cortex-a53-843419=full instead"),
+ abfd, (uint64_t) (bfd_vma) imm);
bfd_set_error (bfd_error_bad_value);
/* This function is called inside a hashtable traversal and the error
handlers called above turn into non-fatal errors. Which means this