diff options
author | Alan Modra <amodra@gmail.com> | 2008-07-28 04:07:32 +0000 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2008-07-28 04:07:32 +0000 |
commit | 14a9197011818108c904f8c8eb5fbba48f3cfd7d (patch) | |
tree | 9365cef928ad49a13356580e77cd41d1c619d94f /binutils/readelf.c | |
parent | 17bdf94d94144206c30bf035c70025231c906439 (diff) | |
download | gdb-14a9197011818108c904f8c8eb5fbba48f3cfd7d.zip gdb-14a9197011818108c904f8c8eb5fbba48f3cfd7d.tar.gz 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/readelf.c')
-rw-r--r-- | binutils/readelf.c | 181 |
1 files changed, 24 insertions, 157 deletions
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; } |