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.
This commit is contained in:
parent
17bdf94d94
commit
14a9197011
6 changed files with 70 additions and 205 deletions
|
@ -1,3 +1,11 @@
|
|||
2008-07-28 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
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.
|
||||
|
||||
2008-07-27 Alan Modra <amodra@bigpond.net.au>
|
||||
|
||||
* elf.c (_bfd_elf_make_section_from_shdr): Ignore return from
|
||||
|
|
30
bfd/bfd-in.h
30
bfd/bfd-in.h
|
@ -128,26 +128,17 @@ typedef BFD_HOST_64_BIT bfd_signed_vma;
|
|||
typedef BFD_HOST_U_64_BIT bfd_size_type;
|
||||
typedef BFD_HOST_U_64_BIT symvalue;
|
||||
|
||||
#ifndef fprintf_vma
|
||||
#if BFD_HOST_64BIT_LONG
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
|
||||
#elif BFD_HOST_64BIT_LONG_LONG
|
||||
#ifndef __MSVCRT__
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016llx", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016llx", x)
|
||||
#define BFD_VMA_FMT "l"
|
||||
#elif defined (__MSVCRT__)
|
||||
#define BFD_VMA_FMT "I64"
|
||||
#else
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016I64x", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016I64x", x)
|
||||
#endif
|
||||
#else
|
||||
#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
|
||||
#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
|
||||
#define fprintf_vma(s,x) \
|
||||
fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#define sprintf_vma(s,x) \
|
||||
sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#define BFD_VMA_FMT "ll"
|
||||
#endif
|
||||
|
||||
#ifndef fprintf_vma
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016" BFD_VMA_FMT "x", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016" BFD_VMA_FMT "x", x)
|
||||
#endif
|
||||
|
||||
#else /* not BFD64 */
|
||||
|
@ -167,8 +158,9 @@ typedef unsigned long symvalue;
|
|||
typedef unsigned long bfd_size_type;
|
||||
|
||||
/* Print a bfd_vma x on stream s. */
|
||||
#define fprintf_vma(s,x) fprintf (s, "%08lx", x)
|
||||
#define sprintf_vma(s,x) sprintf (s, "%08lx", x)
|
||||
#define BFD_VMA_FMT "l"
|
||||
#define fprintf_vma(s,x) fprintf (s, "%08" BFD_VMA_FMT "x", x)
|
||||
#define sprintf_vma(s,x) sprintf (s, "%08" BFD_VMA_FMT "x", x)
|
||||
|
||||
#endif /* not BFD64 */
|
||||
|
||||
|
|
|
@ -135,26 +135,17 @@ typedef BFD_HOST_64_BIT bfd_signed_vma;
|
|||
typedef BFD_HOST_U_64_BIT bfd_size_type;
|
||||
typedef BFD_HOST_U_64_BIT symvalue;
|
||||
|
||||
#ifndef fprintf_vma
|
||||
#if BFD_HOST_64BIT_LONG
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016lx", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016lx", x)
|
||||
#elif BFD_HOST_64BIT_LONG_LONG
|
||||
#ifndef __MSVCRT__
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016llx", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016llx", x)
|
||||
#define BFD_VMA_FMT "l"
|
||||
#elif defined (__MSVCRT__)
|
||||
#define BFD_VMA_FMT "I64"
|
||||
#else
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016I64x", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016I64x", x)
|
||||
#endif
|
||||
#else
|
||||
#define _bfd_int64_low(x) ((unsigned long) (((x) & 0xffffffff)))
|
||||
#define _bfd_int64_high(x) ((unsigned long) (((x) >> 32) & 0xffffffff))
|
||||
#define fprintf_vma(s,x) \
|
||||
fprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#define sprintf_vma(s,x) \
|
||||
sprintf ((s), "%08lx%08lx", _bfd_int64_high (x), _bfd_int64_low (x))
|
||||
#define BFD_VMA_FMT "ll"
|
||||
#endif
|
||||
|
||||
#ifndef fprintf_vma
|
||||
#define sprintf_vma(s,x) sprintf (s, "%016" BFD_VMA_FMT "x", x)
|
||||
#define fprintf_vma(f,x) fprintf (f, "%016" BFD_VMA_FMT "x", x)
|
||||
#endif
|
||||
|
||||
#else /* not BFD64 */
|
||||
|
@ -174,8 +165,9 @@ typedef unsigned long symvalue;
|
|||
typedef unsigned long bfd_size_type;
|
||||
|
||||
/* Print a bfd_vma x on stream s. */
|
||||
#define fprintf_vma(s,x) fprintf (s, "%08lx", x)
|
||||
#define sprintf_vma(s,x) sprintf (s, "%08lx", x)
|
||||
#define BFD_VMA_FMT "l"
|
||||
#define fprintf_vma(s,x) fprintf (s, "%08" BFD_VMA_FMT "x", x)
|
||||
#define sprintf_vma(s,x) sprintf (s, "%08" BFD_VMA_FMT "x", x)
|
||||
|
||||
#endif /* not BFD64 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
static int
|
||||
print_dec_vma (bfd_vma vma, int is_signed)
|
||||
{
|
||||
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
|
||||
{
|
||||
char digit = '0' + (vma & 0x0f);
|
||||
if (digit > '9')
|
||||
digit += 'a' - '0' - 10;
|
||||
*bufp++ = digit;
|
||||
vma >>= 4;
|
||||
}
|
||||
while (vma != 0);
|
||||
nc = bufp - buf;
|
||||
|
||||
while (bufp > buf)
|
||||
putchar (*--bufp);
|
||||
return nc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Print a VMA value. */
|
||||
static int
|
||||
print_vma (bfd_vma vma, print_mode mode)
|
||||
{
|
||||
#ifdef BFD64
|
||||
if (is_32bit_elf)
|
||||
#endif
|
||||
int nc = 0;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case FULL_HEX:
|
||||
return printf ("0x%8.8lx", (unsigned long) vma);
|
||||
case FULL_HEX:
|
||||
nc = printf ("0x");
|
||||
/* Drop through. */
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
case LONG_HEX:
|
||||
#ifdef BFD64
|
||||
else
|
||||
{
|
||||
int nc = 0;
|
||||
if (is_32bit_elf)
|
||||
return nc + printf ("%08.8" BFD_VMA_FMT "x", vma);
|
||||
#endif
|
||||
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:
|
||||
return nc + printf ("%" BFD_VMA_FMT "x", vma);
|
||||
|
||||
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 DEC:
|
||||
return printf ("%" BFD_VMA_FMT "d", 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_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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue