aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2008-07-28 04:07:32 +0000
committerAlan Modra <amodra@gmail.com>2008-07-28 04:07:32 +0000
commit14a9197011818108c904f8c8eb5fbba48f3cfd7d (patch)
tree9365cef928ad49a13356580e77cd41d1c619d94f /binutils
parent17bdf94d94144206c30bf035c70025231c906439 (diff)
downloadfsf-binutils-gdb-14a9197011818108c904f8c8eb5fbba48f3cfd7d.zip
fsf-binutils-gdb-14a9197011818108c904f8c8eb5fbba48f3cfd7d.tar.gz
fsf-binutils-gdb-14a9197011818108c904f8c8eb5fbba48f3cfd7d.tar.bz2
bfd/
PR 6769 * bfd-in.h (BFD_VMA_FMT): Define. (printf_vma, sprintf_vma): Use the above. (_bfd_int64_low, _bfd_int64_high): Delete. * bfd-in2.h: Regenerate. binutils/ PR 6769 * readelf.c (print_dec_vma, print_hex_vma): Delete. (print_vma): Use BFD_VMA_FMT. * size.c (size_number, rprint_number): Likewise.
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog7
-rw-r--r--binutils/readelf.c181
-rw-r--r--binutils/size.c17
3 files changed, 39 insertions, 166 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index fd95457..3ca5ad9 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,10 @@
+2008-07-28 Alan Modra <amodra@bigpond.net.au>
+
+ PR 6769
+ * readelf.c (print_dec_vma, print_hex_vma): Delete.
+ (print_vma): Use BFD_VMA_FMT.
+ * size.c (size_number, rprint_number): Likewise.
+
2008-07-26 Michael Eager <eager@eagercon.com>
* readelf.c (display_power_gnu_attribute): Display
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 8b0e13a..236816d 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -372,177 +372,44 @@ byte_put_little_endian (unsigned char *field, bfd_vma value, int size)
}
}
-#if defined BFD64 && !BFD_HOST_64BIT_LONG && !BFD_HOST_64BIT_LONG_LONG
+/* Print a VMA value. */
static int
-print_dec_vma (bfd_vma vma, int is_signed)
+print_vma (bfd_vma vma, print_mode mode)
{
- char buf[40];
- char *bufp = buf;
int nc = 0;
- if (is_signed && (bfd_signed_vma) vma < 0)
- {
- vma = -vma;
- putchar ('-');
- nc = 1;
- }
-
- do
- {
- *bufp++ = '0' + vma % 10;
- vma /= 10;
- }
- while (vma != 0);
- nc += bufp - buf;
-
- while (bufp > buf)
- putchar (*--bufp);
- return nc;
-}
-
-static int
-print_hex_vma (bfd_vma vma)
-{
- char buf[32];
- char *bufp = buf;
- int nc;
-
- do
+ switch (mode)
{
- char digit = '0' + (vma & 0x0f);
- if (digit > '9')
- digit += 'a' - '0' - 10;
- *bufp++ = digit;
- vma >>= 4;
- }
- while (vma != 0);
- nc = bufp - buf;
+ case FULL_HEX:
+ nc = printf ("0x");
+ /* Drop through. */
- while (bufp > buf)
- putchar (*--bufp);
- return nc;
-}
-#endif
-
-/* Print a VMA value. */
-static int
-print_vma (bfd_vma vma, print_mode mode)
-{
+ case LONG_HEX:
#ifdef BFD64
- if (is_32bit_elf)
+ if (is_32bit_elf)
+ return nc + printf ("%08.8" BFD_VMA_FMT "x", vma);
#endif
- {
- switch (mode)
- {
- case FULL_HEX:
- return printf ("0x%8.8lx", (unsigned long) vma);
-
- case LONG_HEX:
- return printf ("%8.8lx", (unsigned long) vma);
-
- case DEC_5:
- if (vma <= 99999)
- return printf ("%5ld", (long) vma);
- /* Drop through. */
-
- case PREFIX_HEX:
- return printf ("0x%lx", (unsigned long) vma);
-
- case HEX:
- return printf ("%lx", (unsigned long) vma);
-
- case DEC:
- return printf ("%ld", (unsigned long) vma);
-
- case UNSIGNED:
- return printf ("%lu", (unsigned long) vma);
- }
- }
-#ifdef BFD64
- else
- {
- int nc = 0;
+ printf_vma (vma);
+ return nc + 16;
- switch (mode)
- {
- case FULL_HEX:
- nc = printf ("0x");
- /* Drop through. */
+ case DEC_5:
+ if (vma <= 99999)
+ return printf ("%5" BFD_VMA_FMT "d", vma);
+ /* Drop through. */
- case LONG_HEX:
- printf_vma (vma);
- return nc + 16;
+ case PREFIX_HEX:
+ nc = printf ("0x");
+ /* Drop through. */
- case PREFIX_HEX:
- nc = printf ("0x");
- /* Drop through. */
-
- case HEX:
-#if BFD_HOST_64BIT_LONG
- return nc + printf ("%lx", vma);
-#elif BFD_HOST_64BIT_LONG_LONG
-#ifndef __MSVCRT__
- return nc + printf ("%llx", vma);
-#else
- return nc + printf ("%I64x", vma);
-#endif
-#else
- return nc + print_hex_vma (vma);
-#endif
+ case HEX:
+ return nc + printf ("%" BFD_VMA_FMT "x", vma);
- case DEC:
-#if BFD_HOST_64BIT_LONG
- return printf ("%ld", vma);
-#elif BFD_HOST_64BIT_LONG_LONG
-#ifndef __MSVCRT__
- return printf ("%lld", vma);
-#else
- return printf ("%I64d", vma);
-#endif
-#else
- return print_dec_vma (vma, 1);
-#endif
+ case DEC:
+ return printf ("%" BFD_VMA_FMT "d", vma);
- case DEC_5:
-#if BFD_HOST_64BIT_LONG
- if (vma <= 99999)
- return printf ("%5ld", vma);
- else
- return printf ("%#lx", vma);
-#elif BFD_HOST_64BIT_LONG_LONG
-#ifndef __MSVCRT__
- if (vma <= 99999)
- return printf ("%5lld", vma);
- else
- return printf ("%#llx", vma);
-#else
- if (vma <= 99999)
- return printf ("%5I64d", vma);
- else
- return printf ("%#I64x", vma);
-#endif
-#else
- if (vma <= 99999)
- return printf ("%5ld", _bfd_int64_low (vma));
- else
- return print_hex_vma (vma);
-#endif
-
- case UNSIGNED:
-#if BFD_HOST_64BIT_LONG
- return printf ("%lu", vma);
-#elif BFD_HOST_64BIT_LONG_LONG
-#ifndef __MSVCRT__
- return printf ("%llu", vma);
-#else
- return printf ("%I64u", vma);
-#endif
-#else
- return print_dec_vma (vma, 0);
-#endif
- }
+ case UNSIGNED:
+ return printf ("%" BFD_VMA_FMT "u", vma);
}
-#endif
return 0;
}
diff --git a/binutils/size.c b/binutils/size.c
index f035cab..415fee1 100644
--- a/binutils/size.c
+++ b/binutils/size.c
@@ -1,6 +1,7 @@
/* size.c -- report size of various sections of an executable file.
Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
- 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+ 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ Free Software Foundation, Inc.
This file is part of GNU Binutils.
@@ -406,17 +407,15 @@ display_file (char *filename)
}
}
-/* This is what lexical functions are for. */
-
static int
size_number (bfd_size_type num)
{
char buffer[40];
sprintf (buffer,
- (radix == decimal ? "%lu" :
- ((radix == octal) ? "0%lo" : "0x%lx")),
- (unsigned long) num);
+ (radix == decimal ? "%" BFD_VMA_FMT "u" :
+ ((radix == octal) ? "0%" BFD_VMA_FMT "o" : "0x%" BFD_VMA_FMT "x")),
+ num);
return strlen (buffer);
}
@@ -427,9 +426,9 @@ rprint_number (int width, bfd_size_type num)
char buffer[40];
sprintf (buffer,
- (radix == decimal ? "%lu" :
- ((radix == octal) ? "0%lo" : "0x%lx")),
- (unsigned long) num);
+ (radix == decimal ? "%" BFD_VMA_FMT "u" :
+ ((radix == octal) ? "0%" BFD_VMA_FMT "o" : "0x%" BFD_VMA_FMT "x")),
+ num);
printf ("%*s", width, buffer);
}