BFD long long cleanup
authorAlan Modra <amodra@gmail.com>
Mon, 3 Jul 2017 12:29:30 +0000 (21:59 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 3 Jul 2017 12:33:48 +0000 (22:03 +0930)
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
bfd/bfd.c
bfd/coff-rs6000.c
bfd/coff-x86_64.c
bfd/coffcode.h
bfd/elf32-score.c
bfd/vms-alpha.c

index b1e5e65ca6c43ec9e49fbd8d78a381a8fad6fbb9..74cb0c9ed13db77c7356c60a6ac1765241124546 100644 (file)
@@ -1,3 +1,15 @@
+2017-07-03  Alan Modra  <amodra@gmail.com>
+
+       * 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  <amodra@gmail.com>
 
        * elf.c (_bfd_elf_print_private_bfd_data): Use BFD_VMA_FMT to
index c6fce45abf1b7c530dcb99a7a764d42359c17bbb..9c0175f5a41c2a4f6af4c476c88c3627de2bd123 100644 (file)
--- 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
index fabf971346fe863fed2232ec634b5def3498f78d..3c5042fe20401a177044effb05391dfb06828d46 100644 (file)
@@ -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) \
index 928fa7f1fc3e35dbf3002614adb02d76a764113f..de22822e7b2720d5243199b20e755bacd5b05094 100644 (file)
@@ -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;
 
index 3331f4cc51cb5f22e8d4ebe61bd1d21d1d46397b..d6388d7dd376252b0fa5cadd71622ac447412248 100644 (file)
@@ -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));
index 54294763febd15de39647949b5566e925e6fb3cb..3dfe80684ed8d496587597eceed6167fd95a27f3 100644 (file)
@@ -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;
 }
 
index a2cfa337bfad162f0db6a2511899ab976c5b7aa7..91e8b6e0324e527493a7a54d2b3867a3fc95f2e2 100644 (file)
@@ -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;
This page took 0.035192 seconds and 4 git commands to generate.