On Tue, Sep 11, 2007 at 05:14:58PM +0800, zhou drangon wrote: > binutils compile error under x86_64-pc-mingw32, > because it defines BFD_HOST_64BIT_LONG_LONG , but not use in some env, > the following patch may fix it
Thank you. I have applied a completely different patch to elf.c, and modified your readelf.c one a little. * nm.c (value_format_64bit, set_print_radix, print_value): Handle BFD_HOST_64BIT_LONG_LONG. * readelf.c (print_dec_vma): Don't define if BFD_HOST_64BIT_LONG_LONG. (print_vma): Handle BFD_HOST_64BIT_LONG_LONG. (dump_relocations): Likewise. Expand _bfd_int64_low in a number of places. Index: binutils/nm.c =================================================================== RCS file: /cvs/src/src/binutils/nm.c,v retrieving revision 1.54 diff -u -p -r1.54 nm.c --- binutils/nm.c 5 Jul 2007 16:54:45 -0000 1.54 +++ binutils/nm.c 12 Sep 2007 14:52:31 -0000 @@ -160,7 +160,11 @@ static int filename_per_symbol = 0; /* O /* Print formats for printing a symbol value. */ static char value_format_32bit[] = "%08lx"; +#if BFD_HOST_64BIT_LONG static char value_format_64bit[] = "%016lx"; +#elif BFD_HOST_64BIT_LONG_LONG +static char value_format_64bit[] = "%016llx"; +#endif static int print_width = 0; static int print_radix = 16; /* Print formats for printing stab info. */ @@ -269,7 +273,11 @@ set_print_radix (char *radix) else print_radix = 8; value_format_32bit[4] = *radix; +#if BFD_HOST_64BIT_LONG value_format_64bit[5] = *radix; +#elif BFD_HOST_64BIT_LONG_LONG + value_format_64bit[6] = *radix; +#endif other_format[3] = desc_format[3] = *radix; break; default: @@ -1341,7 +1349,7 @@ print_value (bfd *abfd ATTRIBUTE_UNUSED, break; case 64: -#if BFD_HOST_64BIT_LONG +#if BFD_HOST_64BIT_LONG || BFD_HOST_64BIT_LONG_LONG printf (value_format_64bit, val); #else /* We have a 64 bit value to print, but the host is only 32 bit. */ Index: binutils/readelf.c =================================================================== RCS file: /cvs/src/src/binutils/readelf.c,v retrieving revision 1.377 diff -u -p -r1.377 readelf.c --- binutils/readelf.c 10 Sep 2007 09:05:23 -0000 1.377 +++ binutils/readelf.c 12 Sep 2007 14:52:35 -0000 @@ -383,7 +383,7 @@ byte_put_little_endian (unsigned char *f } } -#if defined BFD64 && !BFD_HOST_64BIT_LONG +#if defined BFD64 && !BFD_HOST_64BIT_LONG && !BFD_HOST_64BIT_LONG_LONG static int print_dec_vma (bfd_vma vma, int is_signed) { @@ -491,6 +491,8 @@ print_vma (bfd_vma vma, print_mode mode) case HEX: #if BFD_HOST_64BIT_LONG return nc + printf ("%lx", vma); +#elif BFD_HOST_64BIT_LONG_LONG + return nc + printf ("%llx", vma); #else return nc + print_hex_vma (vma); #endif @@ -498,6 +500,8 @@ print_vma (bfd_vma vma, print_mode mode) case DEC: #if BFD_HOST_64BIT_LONG return printf ("%ld", vma); +#elif BFD_HOST_64BIT_LONG_LONG + return printf ("%lld", vma); #else return print_dec_vma (vma, 1); #endif @@ -508,6 +512,11 @@ print_vma (bfd_vma vma, print_mode mode) return printf ("%5ld", vma); else return printf ("%#lx", vma); +#elif BFD_HOST_64BIT_LONG_LONG + if (vma <= 99999) + return printf ("%5lld", vma); + else + return printf ("%#llx", vma); #else if (vma <= 99999) return printf ("%5ld", _bfd_int64_low (vma)); @@ -518,6 +527,8 @@ print_vma (bfd_vma vma, print_mode mode) case UNSIGNED: #if BFD_HOST_64BIT_LONG return printf ("%lu", vma); +#elif BFD_HOST_64BIT_LONG_LONG + return printf ("%llu", vma); #else return print_dec_vma (vma, 0); #endif @@ -953,15 +964,23 @@ dump_relocations (FILE *file, if (is_32bit_elf) { -#ifdef _bfd_int64_low - printf ("%8.8lx %8.8lx ", _bfd_int64_low (offset), _bfd_int64_low (info)); -#else - printf ("%8.8lx %8.8lx ", offset, info); -#endif + printf ("%8.8lx %8.8lx ", + (unsigned long) offset & 0xffffffff, + (unsigned long) info & 0xffffffff); } else { -#ifdef _bfd_int64_low +#if BFD_HOST_64BIT_LONG + printf (do_wide + ? "%16.16lx %16.16lx " + : "%12.12lx %12.12lx ", + offset, info); +#elif BFD_HOST_64BIT_LONG_LONG + printf (do_wide + ? "%16.16llx %16.16llx " + : "%12.12llx %12.12llx ", + offset, info); +#else printf (do_wide ? "%8.8lx%8.8lx %8.8lx%8.8lx " : "%4.4lx%8.8lx %4.4lx%8.8lx ", @@ -969,11 +988,6 @@ dump_relocations (FILE *file, _bfd_int64_low (offset), _bfd_int64_high (info), _bfd_int64_low (info)); -#else - printf (do_wide - ? "%16.16lx %16.16lx " - : "%12.12lx %12.12lx ", - offset, info); #endif } @@ -1203,11 +1217,7 @@ dump_relocations (FILE *file, } if (rtype == NULL) -#ifdef _bfd_int64_low - printf (_("unrecognized: %-7lx"), _bfd_int64_low (type)); -#else - printf (_("unrecognized: %-7lx"), type); -#endif + printf (_("unrecognized: %-7lx"), (unsigned long) type & 0xffffffff); else printf (do_wide ? "%-22.22s" : "%-17.17s", rtype); @@ -1323,22 +1333,16 @@ dump_relocations (FILE *file, printf (" Type2: "); if (rtype2 == NULL) -#ifdef _bfd_int64_low - printf (_("unrecognized: %-7lx"), _bfd_int64_low (type2)); -#else - printf (_("unrecognized: %-7lx"), type2); -#endif + printf (_("unrecognized: %-7lx"), + (unsigned long) type2 & 0xffffffff); else printf ("%-17.17s", rtype2); printf ("\n Type3: "); if (rtype3 == NULL) -#ifdef _bfd_int64_low - printf (_("unrecognized: %-7lx"), _bfd_int64_low (type3)); -#else - printf (_("unrecognized: %-7lx"), type3); -#endif + printf (_("unrecognized: %-7lx"), + (unsigned long) type3 & 0xffffffff); else printf ("%-17.17s", rtype3); -- Alan Modra Australia Development Lab, IBM _______________________________________________ bug-binutils mailing list bug-binutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-binutils