Remove use of bfd_uint64_t and similar

Requiring C99 means that uses of bfd_uint64_t can be replaced with
uint64_t, and similarly for bfd_int64_t, BFD_HOST_U_64_BIT, and
BFD_HOST_64_BIT.  This patch does that, removes #ifdef BFD_HOST_*
and tidies a few places that print 64-bit values.
This commit is contained in:
Alan Modra
2022-05-27 12:37:21 +09:30
parent aa9b5dbc0f
commit 0e3c1eebb2
45 changed files with 295 additions and 473 deletions

View File

@ -1557,29 +1557,15 @@ get_print_format (void)
padding = "016";
}
const char * length = "l";
if (print_width == 64)
{
#if BFD_HOST_64BIT_LONG
;
#elif BFD_HOST_64BIT_LONG_LONG
#ifndef __MSVCRT__
length = "ll";
#else
length = "I64";
#endif
#endif
}
const char * radix = NULL;
switch (print_radix)
{
case 8: radix = "o"; break;
case 10: radix = "d"; break;
case 16: radix = "x"; break;
case 8: radix = PRIo64; break;
case 10: radix = PRId64; break;
case 16: radix = PRIx64; break;
}
return concat ("%", padding, length, radix, NULL);
return concat ("%", padding, radix, NULL);
}
static void
@ -1874,33 +1860,8 @@ print_value (bfd *abfd ATTRIBUTE_UNUSED, bfd_vma val)
switch (print_width)
{
case 32:
printf (print_format_string, (unsigned long) val);
break;
case 64:
#if BFD_HOST_64BIT_LONG || BFD_HOST_64BIT_LONG_LONG
printf (print_format_string, val);
#else
/* We have a 64 bit value to print, but the host is only 32 bit. */
if (print_radix == 16)
bfd_fprintf_vma (abfd, stdout, val);
else
{
char buf[30];
char *s;
s = buf + sizeof buf;
*--s = '\0';
while (val > 0)
{
*--s = (val % print_radix) + '0';
val /= print_radix;
}
while ((buf + sizeof buf - 1) - s < 16)
*--s = '0';
printf ("%s", s);
}
#endif
printf (print_format_string, (uint64_t) val);
break;
default:

View File

@ -283,15 +283,6 @@ bfd_mach_o_print_flags (const bfd_mach_o_xlat_name *table,
printf ("-");
}
/* Print a bfd_uint64_t, using a platform independent style. */
static void
printf_uint64 (bfd_uint64_t v)
{
printf ("0x%08lx%08lx",
(unsigned long)((v >> 16) >> 16), (unsigned long)(v & 0xffffffffUL));
}
static const char *
bfd_mach_o_get_name_or_null (const bfd_mach_o_xlat_name *table,
unsigned long val)
@ -1729,26 +1720,20 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
}
case BFD_MACH_O_LC_MAIN:
{
bfd_mach_o_main_command *entry = &cmd->command.main;
printf (" entry offset: ");
printf_uint64 (entry->entryoff);
printf ("\n"
" stack size: ");
printf_uint64 (entry->stacksize);
printf ("\n");
break;
bfd_mach_o_main_command *entry = &cmd->command.main;
printf (" entry offset: %#016" PRIx64 "\n"
" stack size: %#016" PRIx64 "\n",
entry->entryoff, entry->stacksize);
break;
}
case BFD_MACH_O_LC_NOTE:
{
bfd_mach_o_note_command *note = &cmd->command.note;
printf (" data owner: %.16s\n", note->data_owner);
printf (" offset: ");
printf_uint64 (note->offset);
printf ("\n"
" size: ");
printf_uint64 (note->size);
printf ("\n");
break;
bfd_mach_o_note_command *note = &cmd->command.note;
printf (" data owner: %.16s\n"
" offset: %#016" PRIx64 "\n"
" size: %#016" PRIx64 "\n",
note->data_owner, note->offset, note->size);
break;
}
case BFD_MACH_O_LC_BUILD_VERSION:
dump_build_version (abfd, cmd);
@ -2013,14 +1998,11 @@ dump_obj_compact_unwind (bfd *abfd,
{
e = (struct mach_o_compact_unwind_64 *) p;
putchar (' ');
printf_uint64 (bfd_get_64 (abfd, e->start));
printf (" %08lx", (unsigned long)bfd_get_32 (abfd, e->length));
putchar (' ');
printf_uint64 (bfd_get_64 (abfd, e->personality));
putchar (' ');
printf_uint64 (bfd_get_64 (abfd, e->lsda));
putchar ('\n');
printf (" %#016" PRIx64 " %#08x %#016" PRIx64 " %#016" PRIx64 "\n",
(uint64_t) bfd_get_64 (abfd, e->start),
(unsigned int) bfd_get_32 (abfd, e->length),
(uint64_t) bfd_get_64 (abfd, e->personality),
(uint64_t) bfd_get_64 (abfd, e->lsda));
printf (" encoding: ");
dump_unwind_encoding (mdata, bfd_get_32 (abfd, e->encoding));

View File

@ -485,41 +485,12 @@ pop_type (struct pr_handle *info)
static void
print_vma (bfd_vma vma, char *buf, bool unsignedp, bool hexp)
{
if (sizeof (vma) <= sizeof (unsigned long))
{
if (hexp)
sprintf (buf, "0x%lx", (unsigned long) vma);
else if (unsignedp)
sprintf (buf, "%lu", (unsigned long) vma);
else
sprintf (buf, "%ld", (long) vma);
}
#if BFD_HOST_64BIT_LONG_LONG
else if (sizeof (vma) <= sizeof (unsigned long long))
{
#ifndef __MSVCRT__
if (hexp)
sprintf (buf, "0x%llx", (unsigned long long) vma);
else if (unsignedp)
sprintf (buf, "%llu", (unsigned long long) vma);
else
sprintf (buf, "%lld", (long long) vma);
#else
if (hexp)
sprintf (buf, "0x%I64x", (unsigned long long) vma);
else if (unsignedp)
sprintf (buf, "%I64u", (unsigned long long) vma);
else
sprintf (buf, "%I64d", (long long) vma);
#endif
}
#endif
if (hexp)
sprintf (buf, "%#" PRIx64, (uint64_t) vma);
else if (unsignedp)
sprintf (buf, "%" PRIu64, (uint64_t) vma);
else
{
buf[0] = '0';
buf[1] = 'x';
sprintf_vma (buf + 2, vma);
}
sprintf (buf, "%" PRId64, (int64_t) vma);
}
/* Start a new compilation unit. */

View File

@ -10729,7 +10729,7 @@ dynamic_section_parisc_val (Elf_Internal_Dyn * entry)
/* Display a VMS time in a human readable format. */
static void
print_vms_time (bfd_int64_t vmstime)
print_vms_time (int64_t vmstime)
{
struct tm *tm = NULL;
time_t unxtime;
@ -20764,7 +20764,7 @@ print_ia64_vms_note (Elf_Internal_Note * pnote)
/* FIXME: Generate an error if descsz > 8 ? */
printf ("0x%016" BFD_VMA_FMT "x\n",
(bfd_vma) byte_get ((unsigned char *)pnote->descdata, 8));
(bfd_vma) byte_get ((unsigned char *) pnote->descdata, 8));
break;
case NT_VMS_LINKTIME:
@ -20773,8 +20773,7 @@ print_ia64_vms_note (Elf_Internal_Note * pnote)
goto desc_size_fail;
/* FIXME: Generate an error if descsz > 8 ? */
print_vms_time
((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8));
print_vms_time (byte_get ((unsigned char *) pnote->descdata, 8));
printf ("\n");
break;
@ -20784,8 +20783,7 @@ print_ia64_vms_note (Elf_Internal_Note * pnote)
goto desc_size_fail;
/* FIXME: Generate an error if descsz > 8 ? */
print_vms_time
((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata, 8));
print_vms_time (byte_get ((unsigned char *) pnote->descdata, 8));
printf ("\n");
break;
@ -20794,16 +20792,15 @@ print_ia64_vms_note (Elf_Internal_Note * pnote)
goto desc_size_fail;
printf (_(" Major id: %u, minor id: %u\n"),
(unsigned) byte_get ((unsigned char *)pnote->descdata, 4),
(unsigned) byte_get ((unsigned char *)pnote->descdata + 4, 4));
(unsigned) byte_get ((unsigned char *) pnote->descdata, 4),
(unsigned) byte_get ((unsigned char *) pnote->descdata + 4, 4));
printf (_(" Last modified : "));
print_vms_time
((bfd_int64_t) byte_get ((unsigned char *)pnote->descdata + 8, 8));
print_vms_time (byte_get ((unsigned char *) pnote->descdata + 8, 8));
printf (_("\n Link flags : "));
printf ("0x%016" BFD_VMA_FMT "x\n",
(bfd_vma) byte_get ((unsigned char *)pnote->descdata + 16, 8));
(bfd_vma) byte_get ((unsigned char *) pnote->descdata + 16, 8));
printf (_(" Header flags: 0x%08x\n"),
(unsigned) byte_get ((unsigned char *)pnote->descdata + 24, 4));
(unsigned) byte_get ((unsigned char *) pnote->descdata + 24, 4));
printf (_(" Image id : %.*s\n"), maxlen - 32, pnote->descdata + 32);
break;
#endif