From ce9116fdbfba8926a7bc25613d39bc3b2ed942fc Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 3 Jul 2017 21:59:30 +0930 Subject: BFD long long cleanup long long isn't supposed to be used without a configure test, to support ancient compilers. Probably not terribly important nowadays. * bfd.c (bfd_scan_vma): Don't use long long unless HAVE_LONG_LONG. * coff-rs6000.c (FMT20): Handle hosts with 64-bit long and Microsoft C library variant of long long format specifier. (PRINT20): Cast value to bfd_uint64_t not long long. * coffcode.h (coff_print_aux): Use BFD_VMA_FMT. * coff-x86_64.c (coff_amd64_reloc): Use bfd_uint64_t rather than long long. Don't cast to bfd_vma. * elf32-score.c (score3_bfd_getl48): Likewise. * vms-alpha.c (_bfd_vms_slurp_eisd): Likewise. --- bfd/ChangeLog | 12 ++++++++++++ bfd/bfd.c | 2 +- bfd/coff-rs6000.c | 8 +++++++- bfd/coff-x86_64.c | 4 ++-- bfd/coffcode.h | 16 ++++------------ bfd/elf32-score.c | 16 ++++++++-------- bfd/vms-alpha.c | 2 +- 7 files changed, 35 insertions(+), 25 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b1e5e65ca6c..74cb0c9ed13 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,15 @@ +2017-07-03 Alan Modra + + * bfd.c (bfd_scan_vma): Don't use long long unless HAVE_LONG_LONG. + * coff-rs6000.c (FMT20): Handle hosts with 64-bit long and + Microsoft C library variant of long long format specifier. + (PRINT20): Cast value to bfd_uint64_t not long long. + * coffcode.h (coff_print_aux): Use BFD_VMA_FMT. + * coff-x86_64.c (coff_amd64_reloc): Use bfd_uint64_t rather than + long long. Don't cast to bfd_vma. + * elf32-score.c (score3_bfd_getl48): Likewise. + * vms-alpha.c (_bfd_vms_slurp_eisd): Likewise. + 2017-07-03 Alan Modra * elf.c (_bfd_elf_print_private_bfd_data): Use BFD_VMA_FMT to diff --git a/bfd/bfd.c b/bfd/bfd.c index c6fce45abf1..9c0175f5a41 100644 --- a/bfd/bfd.c +++ b/bfd/bfd.c @@ -1363,7 +1363,7 @@ bfd_scan_vma (const char *string, const char **end, int base) if (sizeof (bfd_vma) <= sizeof (unsigned long)) return strtoul (string, (char **) end, base); -#ifdef HAVE_STRTOULL +#if defined (HAVE_STRTOULL) && defined (HAVE_LONG_LONG) if (sizeof (bfd_vma) <= sizeof (unsigned long long)) return strtoull (string, (char **) end, base); #endif diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c index fabf971346f..3c5042fe204 100644 --- a/bfd/coff-rs6000.c +++ b/bfd/coff-rs6000.c @@ -1715,12 +1715,18 @@ xcoff_write_armap_old (bfd *abfd, unsigned int elength ATTRIBUTE_UNUSED, } static char buff20[XCOFFARMAGBIG_ELEMENT_SIZE + 1]; +#if BFD_HOST_64BIT_LONG +#define FMT20 "%-20ld" +#elif defined (__MSVCRT__) +#define FMT20 "%-20I64d" +#else #define FMT20 "%-20lld" +#endif #define FMT12 "%-12d" #define FMT12_OCTAL "%-12o" #define FMT4 "%-4d" #define PRINT20(d, v) \ - sprintf (buff20, FMT20, (long long)(v)), \ + sprintf (buff20, FMT20, (bfd_uint64_t)(v)), \ memcpy ((void *) (d), buff20, 20) #define PRINT12(d, v) \ diff --git a/bfd/coff-x86_64.c b/bfd/coff-x86_64.c index 928fa7f1fc3..de22822e7b2 100644 --- a/bfd/coff-x86_64.c +++ b/bfd/coff-x86_64.c @@ -182,9 +182,9 @@ coff_amd64_reloc (bfd *abfd, case 4: { - long long x = bfd_get_64 (abfd, addr); + bfd_uint64_t x = bfd_get_64 (abfd, addr); DOIT (x); - bfd_put_64 (abfd, (bfd_vma) x, addr); + bfd_put_64 (abfd, x, addr); } break; diff --git a/bfd/coffcode.h b/bfd/coffcode.h index 3331f4cc51c..d6388d7dd37 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -2599,23 +2599,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); -#ifdef XCOFF64 - fprintf (file, "val %5lld", - (long long) aux->u.auxent.x_csect.x_scnlen.l); -#else - fprintf (file, "val %5ld", (long) aux->u.auxent.x_csect.x_scnlen.l); -#endif + fprintf (file, "val %5" BFD_VMA_FMT "d", + aux->u.auxent.x_csect.x_scnlen.l); } else { fprintf (file, "indx "); if (! aux->fix_scnlen) -#ifdef XCOFF64 - fprintf (file, "%4lld", - (long long) aux->u.auxent.x_csect.x_scnlen.l); -#else - fprintf (file, "%4ld", (long) aux->u.auxent.x_csect.x_scnlen.l); -#endif + fprintf (file, "%4" BFD_VMA_FMT "d", + 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/elf32-score.c b/bfd/elf32-score.c index 54294763feb..3dfe80684ed 100644 --- a/bfd/elf32-score.c +++ b/bfd/elf32-score.c @@ -227,14 +227,14 @@ static bfd_vma score3_bfd_getl48 (const void *p) { const bfd_byte *addr = p; - unsigned long long v; - - v = (unsigned long long) addr[4]; - v |= (unsigned long long) addr[5] << 8; - v |= (unsigned long long) addr[2] << 16; - v |= (unsigned long long) addr[3] << 24; - v |= (unsigned long long) addr[0] << 32; - v |= (unsigned long long) addr[1] << 40; + bfd_uint64_t v; + + v = (bfd_uint64_t) addr[4]; + v |= (bfd_uint64_t) addr[5] << 8; + v |= (bfd_uint64_t) addr[2] << 16; + v |= (bfd_uint64_t) addr[3] << 24; + v |= (bfd_uint64_t) addr[0] << 32; + v |= (bfd_uint64_t) addr[1] << 40; return v; } diff --git a/bfd/vms-alpha.c b/bfd/vms-alpha.c index a2cfa337bfa..91e8b6e0324 100644 --- a/bfd/vms-alpha.c +++ b/bfd/vms-alpha.c @@ -514,7 +514,7 @@ _bfd_vms_slurp_eisd (bfd *abfd, unsigned int offset) struct vms_eisd *eisd; unsigned int rec_size; unsigned int size; - unsigned long long vaddr; + bfd_uint64_t vaddr; unsigned int flags; unsigned int vbn; char *name = NULL; -- cgit v1.2.1