diff options
author | Nick Clifton <nickc@redhat.com> | 2008-01-25 16:18:41 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2008-01-25 16:18:41 +0000 |
commit | 6e3d6dc1ed34b1a58ed922ce31a5cf63502f4bce (patch) | |
tree | 20b99c7b038e8a3008462a0137410a21b286e071 | |
parent | 53d25da64b00c1cf7f10d04785d66fa003f8bfc9 (diff) | |
download | gdb-6e3d6dc1ed34b1a58ed922ce31a5cf63502f4bce.zip gdb-6e3d6dc1ed34b1a58ed922ce31a5cf63502f4bce.tar.gz gdb-6e3d6dc1ed34b1a58ed922ce31a5cf63502f4bce.tar.bz2 |
Add mingw I64 support for printing long and long long values
-rw-r--r-- | bfd/ChangeLog | 6 | ||||
-rw-r--r-- | bfd/bfd-in.h | 7 | ||||
-rw-r--r-- | bfd/bfd-in2.h | 5 | ||||
-rw-r--r-- | bfd/bfd.c | 4 | ||||
-rw-r--r-- | binutils/ChangeLog | 6 | ||||
-rw-r--r-- | binutils/dwarf.c | 115 | ||||
-rw-r--r-- | binutils/prdbg.c | 11 | ||||
-rw-r--r-- | binutils/readelf.c | 34 | ||||
-rw-r--r-- | binutils/strings.c | 26 | ||||
-rw-r--r-- | gas/ChangeLog | 5 | ||||
-rw-r--r-- | gas/read.c | 5 |
11 files changed, 179 insertions, 45 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 85d809a..42d637c 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2008-01-25 Kai Tietz <kai.tietz@onevision.com> + + * bfd-in.h: Add mingw I64 support. + * bfd-in2.h: Regenerated. + * bfd.c: (bfd_get_sign_extend_vma): Add pe-x86-64 and pei-x86-64. + 2008-01-21 Alan Modra <amodra@bigpond.net.au> PR 4453 diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index f37efb2..43c342c 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -1,7 +1,7 @@ /* Main header file for the bfd library -- portable access to object files. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Contributed by Cygnus Support. @@ -133,9 +133,14 @@ typedef BFD_HOST_U_64_BIT symvalue; #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) #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) \ diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 9e18548..b514ad1 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -140,9 +140,14 @@ typedef BFD_HOST_U_64_BIT symvalue; #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) #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) \ @@ -1,6 +1,6 @@ /* Generic BFD library interface and support routines. Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. Written by Cygnus Support. @@ -916,6 +916,8 @@ bfd_get_sign_extend_vma (bfd *abfd) if (CONST_STRNEQ (name, "coff-go32") || strcmp (name, "pe-i386") == 0 || strcmp (name, "pei-i386") == 0 + || strcmp (name, "pe-x86-64") == 0 + || strcmp (name, "pei-x86-64") == 0 || strcmp (name, "pe-arm-wince-little") == 0 || strcmp (name, "pei-arm-wince-little") == 0) return 1; diff --git a/binutils/ChangeLog b/binutils/ChangeLog index 9b8978e..3a4ec73 100644 --- a/binutils/ChangeLog +++ b/binutils/ChangeLog @@ -1,3 +1,9 @@ +2008-01-25 Kai Tietz <kai.tietz@onevision.com> + + * prdbg.c: Correct formatter style use. + * readelf.c: Likewise. + * strings.c: Likewise. + 2008-01-25 Nick Clifton <nickc@redhat.com> * po/ru.po: Updated Russian translation. diff --git a/binutils/dwarf.c b/binutils/dwarf.c index f211237..df83be9 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -1007,19 +1007,20 @@ decode_location_expression (unsigned char * data, } static unsigned char * -read_and_display_attr_value (unsigned long attribute, - unsigned long form, +read_and_display_attr_value (unsigned long attribute, + unsigned long form, unsigned char * data, - unsigned long cu_offset, - unsigned long pointer_size, - unsigned long offset_size, - int dwarf_version, - debug_info * debug_info_p, - int do_loc, - unsigned char * section_start) + unsigned long cu_offset, + unsigned long pointer_size, + unsigned long offset_size, + int dwarf_version, + debug_info * debug_info_p, + int do_loc, + struct dwarf_section * section) { unsigned long uvalue = 0; unsigned char *block_start = NULL; + unsigned char * orig_data = data; unsigned int bytes_read; switch (form) @@ -1092,7 +1093,7 @@ read_and_display_attr_value (unsigned long attribute, cu_offset, pointer_size, offset_size, dwarf_version, debug_info_p, do_loc, - section_start); + section); } switch (form) @@ -1479,23 +1480,29 @@ read_and_display_attr_value (unsigned long attribute, case DW_AT_import: { - unsigned long abbrev_number; - abbrev_entry * entry; - if (form == DW_FORM_ref1 || form == DW_FORM_ref2 || form == DW_FORM_ref4) uvalue += cu_offset; - abbrev_number = read_leb128 (section_start + uvalue, NULL, 0); + if (uvalue >= section->size) + warn (_("Offset %lx used as value for DW_AT_import attribute of DIE at offset %lx is too big.\n"), + uvalue, (long int)(orig_data - section->start)); + else + { + unsigned long abbrev_number; + abbrev_entry * entry; + + abbrev_number = read_leb128 (section->start + uvalue, NULL, 0); - printf ("[Abbrev Number: %ld", abbrev_number); - for (entry = first_abbrev; entry != NULL; entry = entry->next) - if (entry->entry == abbrev_number) - break; - if (entry != NULL) - printf (" (%s)", get_TAG_name (entry->tag)); - printf ("]"); + printf ("[Abbrev Number: %ld", abbrev_number); + for (entry = first_abbrev; entry != NULL; entry = entry->next) + if (entry->entry == abbrev_number) + break; + if (entry != NULL) + printf (" (%s)", get_TAG_name (entry->tag)); + printf ("]"); + } } break; @@ -1661,23 +1668,23 @@ get_AT_name (unsigned long attribute) } static unsigned char * -read_and_display_attr (unsigned long attribute, - unsigned long form, +read_and_display_attr (unsigned long attribute, + unsigned long form, unsigned char * data, - unsigned long cu_offset, - unsigned long pointer_size, - unsigned long offset_size, - int dwarf_version, - debug_info * debug_info_p, - int do_loc, - unsigned char * section_start) + unsigned long cu_offset, + unsigned long pointer_size, + unsigned long offset_size, + int dwarf_version, + debug_info * debug_info_p, + int do_loc, + struct dwarf_section * section) { if (!do_loc) printf (" %-18s:", get_AT_name (attribute)); data = read_and_display_attr_value (attribute, form, data, cu_offset, pointer_size, offset_size, dwarf_version, debug_info_p, - do_loc, section_start); + do_loc, section); if (!do_loc) printf ("\n"); return data; @@ -1689,7 +1696,8 @@ read_and_display_attr (unsigned long attribute, anything to the user. */ static int -process_debug_info (struct dwarf_section *section, void *file, +process_debug_info (struct dwarf_section *section, + void *file, int do_loc) { unsigned char *start = section->start; @@ -1954,7 +1962,7 @@ process_debug_info (struct dwarf_section *section, void *file, offset_size, compunit.cu_version, debug_information + unit, - do_loc, section->start); + do_loc, section); } if (entry->children) @@ -2289,6 +2297,21 @@ display_debug_lines (struct dwarf_section *section, void *file) return 1; } +static debug_info * +find_debug_info_for_offset (unsigned long offset) +{ + unsigned int i; + + if (num_debug_info_entries == DEBUG_INFO_UNAVAILABLE) + return NULL; + + for (i = 0; i < num_debug_info_entries; i++) + if (debug_information[i].cu_offset == offset) + return debug_information + i; + + return NULL; +} + static int display_debug_pubnames (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) @@ -2297,6 +2320,10 @@ display_debug_pubnames (struct dwarf_section *section, unsigned char *start = section->start; unsigned char *end = start + section->size; + /* It does not matter if this load fails, + we test for that later on. */ + load_debug_info (file); + printf (_("Contents of the %s section:\n\n"), section->name); while (start < end) @@ -2324,8 +2351,16 @@ display_debug_pubnames (struct dwarf_section *section, pubnames.pn_version = byte_get (data, 2); data += 2; + pubnames.pn_offset = byte_get (data, offset_size); data += offset_size; + + if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE + && num_debug_info_entries > 0 + && find_debug_info_for_offset (pubnames.pn_offset) == NULL) + warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), + pubnames.pn_offset, section->name); + pubnames.pn_size = byte_get (data, offset_size); data += offset_size; @@ -2348,7 +2383,7 @@ display_debug_pubnames (struct dwarf_section *section, pubnames.pn_length); printf (_(" Version: %d\n"), pubnames.pn_version); - printf (_(" Offset into .debug_info section: %ld\n"), + printf (_(" Offset into .debug_info section: 0x%lx\n"), pubnames.pn_offset); printf (_(" Size of area in .debug_info section: %ld\n"), pubnames.pn_size); @@ -2770,6 +2805,10 @@ display_debug_aranges (struct dwarf_section *section, printf (_("The section %s contains:\n\n"), section->name); + /* It does not matter if this load fails, + we test for that later on. */ + load_debug_info (file); + while (start < end) { unsigned char *hdrptr; @@ -2806,6 +2845,12 @@ display_debug_aranges (struct dwarf_section *section, arange.ar_info_offset = byte_get (hdrptr, offset_size); hdrptr += offset_size; + if (num_debug_info_entries != DEBUG_INFO_UNAVAILABLE + && num_debug_info_entries > 0 + && find_debug_info_for_offset (arange.ar_info_offset) == NULL) + warn (_(".debug_info offset of 0x%lx in %s section does not point to a CU header.\n"), + arange.ar_info_offset, section->name); + arange.ar_pointer_size = byte_get (hdrptr, 1); hdrptr += 1; @@ -2820,7 +2865,7 @@ display_debug_aranges (struct dwarf_section *section, printf (_(" Length: %ld\n"), arange.ar_length); printf (_(" Version: %d\n"), arange.ar_version); - printf (_(" Offset into .debug_info: %lx\n"), arange.ar_info_offset); + printf (_(" Offset into .debug_info: 0x%lx\n"), arange.ar_info_offset); printf (_(" Pointer Size: %d\n"), arange.ar_pointer_size); printf (_(" Segment Size: %d\n"), arange.ar_segment_size); diff --git a/binutils/prdbg.c b/binutils/prdbg.c index 14e371c..39b9e3f 100644 --- a/binutils/prdbg.c +++ b/binutils/prdbg.c @@ -502,12 +502,21 @@ print_vma (bfd_vma vma, char *buf, bfd_boolean unsignedp, bfd_boolean hexp) #if BFD_HOST_64BIT_LONG_LONG else if (sizeof (vma) <= sizeof (unsigned long long)) { +#ifndef __MSVCRT__ if (hexp) sprintf (buf, "0x%llx", (unsigned long long) vma); else if (unsignedp) sprintf (buf, "%llu", (unsigned long long) vma); else sprintf (buf, "%lld", (long long) vma); +#else + if (hexp) + sprintf (buf, "0x%I64x", (unsigned long long) vma); + else if (unsignedp) + sprintf (buf, "%I64u", (unsigned long long) vma); + else + sprintf (buf, "%I64d", (long long) vma); +#endif } #endif else @@ -1942,8 +1951,6 @@ tg_start_compilation_unit (void * p, const char *filename ATTRIBUTE_UNUSED) { struct pr_handle *info = (struct pr_handle *) p; - fprintf (stderr, "New compilation unit: %s\n", filename); - free (info->filename); /* Should it be relative? best way to do it here?. */ info->filename = strdup (filename); diff --git a/binutils/readelf.c b/binutils/readelf.c index 1631a94..807b0f1 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -1,6 +1,6 @@ /* readelf.c -- display contents of an ELF format file - Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 - Free Software Foundation, Inc. + Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, + 2008 Free Software Foundation, Inc. Originally developed by Eric Youngdale <eric@andante.jic.com> Modifications by Nick Clifton <nickc@redhat.com> @@ -493,8 +493,12 @@ print_vma (bfd_vma vma, print_mode mode) #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 @@ -502,8 +506,12 @@ print_vma (bfd_vma vma, print_mode mode) #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 @@ -514,12 +522,19 @@ print_vma (bfd_vma vma, print_mode mode) 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); @@ -529,8 +544,12 @@ print_vma (bfd_vma vma, print_mode mode) #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 } @@ -990,12 +1009,19 @@ dump_relocations (FILE *file, : "%12.12lx %12.12lx ", offset, info); #elif BFD_HOST_64BIT_LONG_LONG +#ifndef __MSVCRT__ printf (do_wide ? "%16.16llx %16.16llx " : "%12.12llx %12.12llx ", offset, info); #else printf (do_wide + ? "%16.16I64x %16.16I64x " + : "%12.12I64x %12.12I64x ", + offset, info); +#endif +#else + printf (do_wide ? "%8.8lx%8.8lx %8.8lx%8.8lx " : "%4.4lx%8.8lx %4.4lx%8.8lx ", _bfd_int64_high (offset), @@ -7820,7 +7846,11 @@ dump_section_as_strings (Elf_Internal_Shdr *section, FILE *file) if (data < end) { +#ifndef __MSVCRT__ printf (" [%6tx] %s\n", data - start, data); +#else + printf (" [%6Ix] %s\n", (size_t) (data - start), data); +#endif data += strlen (data); some_strings_shown = TRUE; } diff --git a/binutils/strings.c b/binutils/strings.c index c1e2077..650b8cb 100644 --- a/binutils/strings.c +++ b/binutils/strings.c @@ -1,6 +1,6 @@ /* strings -- print the strings of printable characters in files Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -593,7 +593,13 @@ print_strings (const char *filename, FILE *stream, file_off address, case 8: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7llo ", (unsigned long long) start); + { +#ifndef __MSVCRT__ + printf ("%7llo ", (unsigned long long) start); +#else + printf ("%7I64o ", (unsigned long long) start); +#endif + } else #elif !BFD_HOST_64BIT_LONG if (start != (unsigned long) start) @@ -606,7 +612,13 @@ print_strings (const char *filename, FILE *stream, file_off address, case 10: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7lld ", (unsigned long long) start); + { +#ifndef __MSVCRT__ + printf ("%7lld ", (unsigned long long) start); +#else + printf ("%7I64d ", (unsigned long long) start); +#endif + } else #elif !BFD_HOST_64BIT_LONG if (start != (unsigned long) start) @@ -619,7 +631,13 @@ print_strings (const char *filename, FILE *stream, file_off address, case 16: #if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2) if (sizeof (start) > sizeof (long)) - printf ("%7llx ", (unsigned long long) start); + { +#ifndef __MSVCRT__ + printf ("%7llx ", (unsigned long long) start); +#else + printf ("%7I64x ", (unsigned long long) start); +#endif + } else #elif !BFD_HOST_64BIT_LONG if (start != (unsigned long) start) diff --git a/gas/ChangeLog b/gas/ChangeLog index f5334ea..2dec3db 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2008-01-25 Kai Tietz <kai.tietz@onevision.com> + + * read.c: (emit_expr): Correct for mingw use of printf size + specifier. + 2008-01-24 Bob Wilson <bob.wilson@acm.org> * doc/c-xtensa.texi (Xtensa Syntax): Clarify handling of opcodes that @@ -4112,9 +4112,14 @@ emit_expr (expressionS *exp, unsigned int nbytes) || (get & hibit) == 0)) { /* Leading bits contain both 0s & 1s. */ #if defined (BFD64) && BFD_HOST_64BIT_LONG_LONG +#ifndef __MSVCRT__ as_warn (_("value 0x%llx truncated to 0x%llx"), (unsigned long long) get, (unsigned long long) use); #else + as_warn (_("value 0x%I64x truncated to 0x%I64x"), + (unsigned long long) get, (unsigned long long) use); +#endif +#else as_warn (_("value 0x%lx truncated to 0x%lx"), (unsigned long) get, (unsigned long) use); #endif |