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.
This commit is contained in:
Alan Modra 2017-07-03 21:59:30 +09:30
parent cd9af601e6
commit ce9116fdbf
7 changed files with 34 additions and 24 deletions

View 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

View File

@ -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

View 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) \

View 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;

View 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));

View File

@ -227,14 +227,14 @@ static bfd_vma
score3_bfd_getl48 (const void *p)
{
const bfd_byte *addr = p;
unsigned long long v;
bfd_uint64_t 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;
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;
}

View 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;