]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Add mingw I64 support for printing long and long long values
authorNick Clifton <nickc@redhat.com>
Fri, 25 Jan 2008 16:18:41 +0000 (16:18 +0000)
committerNick Clifton <nickc@redhat.com>
Fri, 25 Jan 2008 16:18:41 +0000 (16:18 +0000)
bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/bfd.c
binutils/ChangeLog
binutils/dwarf.c
binutils/prdbg.c
binutils/readelf.c
binutils/strings.c
gas/ChangeLog
gas/read.c

index 85d809ae5bfd6610db497d9b791428aa9de65d0d..42d637cd6ca254e7eab05681062ce1714c87c097 100644 (file)
@@ -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
index f37efb2dbb08345182edff52ea7460823ae47e83..43c342c7f264de64181fa426b108bd64669fd6af 100644 (file)
@@ -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) \
index 9e185489470383eacd6366046a696192f0989b97..b514ad18362d93088f5c109a3c8180e576ab5f14 100644 (file)
@@ -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) \
index a2302f8d0fa1b1359d0f503e91fd4ee451ec4aeb..da27baab884e9f9b5658824324430edb7c6b589d 100644 (file)
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -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;
index 9b8978e1ca66c50c182776cc223066a07e116d58..3a4ec73bf3993d53e9932db5ece33445b7cb1a08 100644 (file)
@@ -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.
index f211237599b46c9cc8c296f699b0e60cd97414fe..df83be9a029beb252034a8b4228320fafa5db1c4 100644 (file)
@@ -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);
 
index 14e371c2bc39d190d22a9076d03c228d0c9d10d9..39b9e3fb8cc5bc52b3d32dd98aa83587932a3b70 100644 (file)
@@ -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);
index 1631a94dcccc9366e7a1731bdbd2d42fcb196198..807b0f1f26ed14ca2ee1464d0e40ef4c42d65250 100644 (file)
@@ -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,7 +493,11 @@ 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,7 +506,11 @@ 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,10 +522,17 @@ 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));
@@ -529,7 +544,11 @@ 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,10 +1009,17 @@ 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 "
@@ -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;
        }
index c1e20770d11087ce2cfe718c2b4177277e922156..650b8cbf414e2d5fed4fbaf915cedfc64c802ddf 100644 (file)
@@ -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)
index f5334eaf991329d88a103ccd15d8b38a0d2350ce..2dec3db14a4f5c1b97c8e54d30bceab8c59d9fd2 100644 (file)
@@ -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
index 376e1575588c594d360aaaa20aa5594a12429a9e..109ab23255126ec2e0486078f3c4528cd565b4f4 100644 (file)
@@ -4112,8 +4112,13 @@ 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);