diff options
author | Alan Modra <amodra@gmail.com> | 2022-08-01 11:33:46 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2022-08-01 13:52:18 +0930 |
commit | f493c2174ef99a43c0a5d89179122f857955d738 (patch) | |
tree | 62cc84715e6a801434dce9cd6cb7760e94110d74 /ld | |
parent | 48ca1b26b99c8fd5bc21f5c69b6b666d9b6b9726 (diff) | |
download | gdb-f493c2174ef99a43c0a5d89179122f857955d738.zip gdb-f493c2174ef99a43c0a5d89179122f857955d738.tar.gz gdb-f493c2174ef99a43c0a5d89179122f857955d738.tar.bz2 |
Get rid of fprintf_vma and sprintf_vma
These two macros print either a 16 digit hex number or an 8 digit
hex number. Unfortunately they depend on both target and host, which
means that the output for 32-bit targets may be either 8 or 16 hex
digits.
Replace them in most cases with code that prints a bfd_vma using
PRIx64. In some cases, deliberately lose the leading zeros.
This change some output, notably in base/offset fields of m68k
disassembly which I think looks better that way, and in error
messages. I've kept leading zeros in symbol dumps (objdump -t)
and in PE header dumps.
bfd/
* bfd-in.h (fprintf_vma, sprintf_vma, printf_vma): Delete.
* bfd-in2.h: Regenerate.
* bfd.c (bfd_sprintf_vma): Don't use sprintf_vma.
(bfd_fprintf_vma): Don't use fprintf_vma.
* coff-rs6000.c (xcoff_reloc_type_tls): Don't use sprintf_vma.
Instead use PRIx64 to print bfd_vma values.
(xcoff_ppc_relocate_section): Likewise.
* cofflink.c (_bfd_coff_write_global_sym): Likewise.
* mmo.c (mmo_write_symbols_and_terminator): Likewise.
* srec.c (srec_write_symbols): Likewise.
* elf32-xtensa.c (print_r_reloc): Similarly for fprintf_vma.
* pei-x86_64.c (pex64_dump_xdata): Likewise.
(pex64_bfd_print_pdata_section): Likewise.
* som.c (som_print_symbol): Likewise.
* ecoff.c (_bfd_ecoff_print_symbol): Use bfd_fprintf_vma.
opcodes/
* dis-buf.c (perror_memory, generic_print_address): Don't use
sprintf_vma. Instead use PRIx64 to print bfd_vma values.
* i386-dis.c (print_operand_value, print_displacement): Likewise.
* m68k-dis.c (print_base, print_indexed): Likewise.
* ns32k-dis.c (print_insn_arg): Likewise.
* ia64-gen.c (_opcode_int64_low, _opcode_int64_high): Delete.
(opcode_fprintf_vma): Delete.
(print_main_table): Use PRIx64 to print opcode.
binutils/
* od-macho.c: Replace all uses of printf_vma with bfd_printf_vma.
* objcopy.c (copy_object): Don't use sprintf_vma. Instead use
PRIx64 to print bfd_vma values.
(copy_main): Likewise.
* readelf.c (CHECK_ENTSIZE_VALUES): Likewise.
(dynamic_section_mips_val): Likewise.
(print_vma): Don't use printf_vma. Instead use PRIx64 to print
bfd_vma values.
(dump_ia64_vms_dynamic_fixups): Likewise.
(process_version_sections): Likewise.
* rddbg.c (stab_context): Likewise.
gas/
* config/tc-i386.c (offset_in_range): Don't use sprintf_vma.
Instead use PRIx64 to print bfd_vma values.
(md_assemble): Likewise.
* config/tc-mips.c (load_register, macro): Likewise.
* messages.c (as_internal_value_out_of_range): Likewise.
* read.c (emit_expr_with_reloc): Likewise.
* config/tc-ia64.c (note_register_values): Don't use fprintf_vma.
Instead use PRIx64 to print bfd_vma values.
(print_dependency): Likewise.
* listing.c (list_symbol_table): Use bfd_sprintf_vma.
* symbols.c (print_symbol_value_1): Use %p to print pointers.
(print_binary): Likewise.
(print_expr_1): Use PRIx64 to print bfd_vma values.
* write.c (print_fixup): Use %p to print pointers. Don't use
fprintf_vma.
* testsuite/gas/all/overflow.l: Update expected output.
* testsuite/gas/m68k/mcf-mov3q.d: Likewise.
* testsuite/gas/m68k/operands.d: Likewise.
* testsuite/gas/s12z/truncated.d: Likewise.
ld/
* deffilep.y (def_file_print): Don't use fprintf_vma. Instead
use PRIx64 to print bfd_vma values.
* emultempl/armelf.em (gld${EMULATION_NAME}_finish): Don't use
sprintf_vma. Instead use PRIx64 to print bfd_vma values.
* emultempl/pe.em (gld${EMULATION_NAME}_finish): Likewise.
* ldlang.c (lang_map): Use %V to print region origin.
(lang_one_common): Don't use sprintf_vma.
* ldmisc.c (vfinfo): Don't use fprintf_vma or sprintf_vma.
* pe-dll.c (pe_dll_generate_def_file): Likewise.
gdb/
* remote.c (remote_target::trace_set_readonly_regions): Replace
uses of sprintf_vma with bfd_sprintf_vma.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/deffilep.y | 7 | ||||
-rw-r--r-- | ld/emultempl/armelf.em | 5 | ||||
-rw-r--r-- | ld/emultempl/pe.em | 5 | ||||
-rw-r--r-- | ld/ldlang.c | 19 | ||||
-rw-r--r-- | ld/ldmisc.c | 28 | ||||
-rw-r--r-- | ld/pe-dll.c | 6 |
6 files changed, 16 insertions, 54 deletions
diff --git a/ld/deffilep.y b/ld/deffilep.y index 3f610dd..8c7a0dc 100644 --- a/ld/deffilep.y +++ b/ld/deffilep.y @@ -503,11 +503,8 @@ def_file_print (FILE *file, def_file *fdef) if (fdef->is_dll != -1) fprintf (file, " is dll: %s\n", fdef->is_dll ? "yes" : "no"); if (fdef->base_address != (bfd_vma) -1) - { - fprintf (file, " base address: 0x"); - fprintf_vma (file, fdef->base_address); - fprintf (file, "\n"); - } + fprintf (file, " base address: 0x%" PRIx64 "\n", + (uint64_t) fdef->base_address); if (fdef->description) fprintf (file, " description: `%s'\n", fdef->description); if (fdef->stack_reserve != -1) diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em index 8f5334d..1769ec5 100644 --- a/ld/emultempl/armelf.em +++ b/ld/emultempl/armelf.em @@ -497,10 +497,7 @@ gld${EMULATION_NAME}_finish (void) /* Now convert this value into a string and store it in entry_symbol where the lang_finish() function will pick it up. */ - buffer[0] = '0'; - buffer[1] = 'x'; - - sprintf_vma (buffer + 2, val); + sprintf (buffer, "0x%" PRIx64, (uint64_t) val); if (params.thumb_entry_symbol != NULL && entry_symbol.name != NULL && entry_from_cmdline) diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 892bf70..2fd4ff4 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1980,10 +1980,7 @@ gld${EMULATION_NAME}_finish (void) /* Now convert this value into a string and store it in entry_symbol where the lang_finish() function will pick it up. */ - buffer[0] = '0'; - buffer[1] = 'x'; - - sprintf_vma (buffer + 2, val); + sprintf (buffer, "0x%" PRIx64, (uint64_t) val); if (entry_symbol.name != NULL && entry_from_cmdline) einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"), diff --git a/ld/ldlang.c b/ld/ldlang.c index f12c096..e7bc9f2 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -2297,21 +2297,9 @@ lang_map (void) for (m = lang_memory_region_list; m != NULL; m = m->next) { - char buf[100]; - int len; - fprintf (config.map_file, "%-16s ", m->name_list.name); - sprintf_vma (buf, m->origin); - minfo ("0x%s ", buf); - len = strlen (buf); - while (len < 16) - { - print_space (); - ++len; - } - - minfo ("0x%V", m->length); + minfo ("0x%V 0x%V", m->origin, m->length); if (m->flags || m->not_flags) { #ifndef BFD64 @@ -7317,10 +7305,7 @@ lang_one_common (struct bfd_link_hash_entry *h, void *info) } minfo ("0x"); - if (size <= 0xffffffff) - sprintf (buf, "%lx", (unsigned long) size); - else - sprintf_vma (buf, size); + sprintf (buf, "%" PRIx64, (uint64_t) size); minfo ("%s", buf); len = strlen (buf); diff --git a/ld/ldmisc.c b/ld/ldmisc.c index e204811..ee52487 100644 --- a/ld/ldmisc.c +++ b/ld/ldmisc.c @@ -241,25 +241,18 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning) case 'V': /* hex bfd_vma */ { - bfd_vma value = args[arg_no].v; + uint64_t value = args[arg_no].v; ++arg_count; - fprintf_vma (fp, value); + fprintf (fp, "%016" PRIx64, value); } break; case 'v': /* hex bfd_vma, no leading zeros */ { - char buf[100]; - char *p = buf; - bfd_vma value = args[arg_no].v; + uint64_t value = args[arg_no].v; ++arg_count; - sprintf_vma (p, value); - while (*p == '0') - p++; - if (!*p) - p--; - fputs (p, fp); + fprintf (fp, "%" PRIx64, value); } break; @@ -268,24 +261,19 @@ vfinfo (FILE *fp, const char *fmt, va_list ap, bool is_warning) 8 spaces. */ { char buf[100]; - bfd_vma value; - char *p; + uint64_t value; int len; value = args[arg_no].v; ++arg_count; - sprintf_vma (buf, value); - for (p = buf; *p == '0'; ++p) - ; - if (*p == '\0') - --p; - len = strlen (p); + sprintf (buf, "%" PRIx64, value); + len = strlen (buf); while (len < 8) { putc (' ', fp); ++len; } - fprintf (fp, "0x%s", p); + fprintf (fp, "0x%s", buf); } break; diff --git a/ld/pe-dll.c b/ld/pe-dll.c index db2c75d..24a5118 100644 --- a/ld/pe-dll.c +++ b/ld/pe-dll.c @@ -1812,10 +1812,8 @@ pe_dll_generate_def_file (const char *pe_out_def_filename) quoteput (pe_def_file->name, out, 1); if (pe_data (link_info.output_bfd)->pe_opthdr.ImageBase) - { - fprintf (out, " BASE=0x"); - fprintf_vma (out, ((bfd_vma) pe_data (link_info.output_bfd)->pe_opthdr.ImageBase)); - } + fprintf (out, " BASE=0x%" PRIx64, + (uint64_t) pe_data (link_info.output_bfd)->pe_opthdr.ImageBase); fprintf (out, "\n"); } |