OSDN Git Service

* readelf.c (target_specific_reloc_handling): New function:
authorNick Clifton <nickc@redhat.com>
Mon, 22 Jun 2009 08:46:13 +0000 (08:46 +0000)
committerNick Clifton <nickc@redhat.com>
Mon, 22 Jun 2009 08:46:13 +0000 (08:46 +0000)
        Processes relocs in a target specific manner.
        (debug_apply_relocations): Use the new function.
        * dwarf.c (display_debug_loc): End the dump with a blank line.
        (struct debug_display): Enable reloc processing for .debug_aranges
        and .debug_loc sections.

binutils/ChangeLog
binutils/dwarf.c
binutils/readelf.c

index 086df79..acce3a8 100644 (file)
@@ -1,3 +1,12 @@
+2009-06-22  Nick Clifton  <nickc@redhat.com>
+
+       * readelf.c (target_specific_reloc_handling): New function:
+       Processes relocs in a target specific manner.
+       (debug_apply_relocations): Use the new function.
+       * dwarf.c (display_debug_loc): End the dump with a blank line.
+       (struct debug_display): Enable reloc processing for .debug_aranges
+       and .debug_loc sections.
+
 2009-06-19  Nick Clifton  <nickc@redhat.com>
 
        * ar.c (usage): Do not use #ifdef inside _("...).
index c8b10f0..b524d17 100644 (file)
@@ -3254,6 +3254,7 @@ display_debug_loc (struct dwarf_section *section, void *file)
   if (start < section_end)
     warn (_("There are %ld unused bytes at the end of section %s\n"),
          (long) (section_end - start), section->name);
+  putchar ('\n');
   return 1;
 }
 
@@ -4865,7 +4866,7 @@ struct dwarf_section_display debug_displays[] =
   { { ".debug_abbrev",         ".zdebug_abbrev",       NULL,   NULL,   0,      0 },
     display_debug_abbrev,              &do_debug_abbrevs,      0,      0 },
   { { ".debug_aranges",                ".zdebug_aranges",      NULL,   NULL,   0,      0 },
-    display_debug_aranges,             &do_debug_aranges,      0,      0 },
+    display_debug_aranges,             &do_debug_aranges,      1,      0 },
   { { ".debug_frame",          ".zdebug_frame",        NULL,   NULL,   0,      0 },
     display_debug_frames,              &do_debug_frames,       1,      0 },
   { { ".debug_info",           ".zdebug_info",         NULL,   NULL,   0,      0 },
@@ -4881,7 +4882,7 @@ struct dwarf_section_display debug_displays[] =
   { { ".debug_str",            ".zdebug_str",          NULL,   NULL,   0,      0 },
     display_debug_str,                 &do_debug_str,          0,      0 },
   { { ".debug_loc",            ".zdebug_loc",          NULL,   NULL,   0,      0 },
-    display_debug_loc,                 &do_debug_loc,          0,      0 },
+    display_debug_loc,                 &do_debug_loc,          1,      0 },
   { { ".debug_pubtypes",       ".zdebug_pubtypes",     NULL,   NULL,   0,      0 },
     display_debug_pubnames,            &do_debug_pubnames,     0,      0 },
   { { ".debug_ranges",         ".zdebug_ranges",       NULL,   NULL,   0,      0 },
index 7c45ade..87c8119 100644 (file)
@@ -6436,6 +6436,7 @@ get_ver_flags (unsigned int flags)
 }
 
 /* Display the contents of the version sections.  */
+
 static int
 process_version_sections (FILE * file)
 {
@@ -8337,6 +8338,54 @@ uncompress_section_contents (unsigned char ** buffer, dwarf_size_type * size)
 #endif  /* HAVE_ZLIB_H */
 }
 
+/* Check to see if the given reloc needs to be handled in a target specific
+   manner.  If so then process the reloc and return TRUE otherwise return
+   FALSE.  */
+
+static bfd_boolean
+target_specific_reloc_handling (Elf_Internal_Rela * reloc,
+                               unsigned char *     start,
+                               Elf_Internal_Sym *  symtab)
+{
+  unsigned int reloc_type = get_reloc_type (reloc->r_info);
+
+  switch (elf_header.e_machine)
+    {
+    case EM_MN10300:
+    case EM_CYGNUS_MN10300:
+      {
+       static Elf_Internal_Sym * saved_sym = NULL;
+
+       switch (reloc_type)
+         {
+         case 34: /* R_MN10300_ALIGN */
+           return TRUE;
+         case 33: /* R_MN10300_SYM_DIFF */
+           saved_sym = symtab + get_reloc_symindex (reloc->r_info);
+           return TRUE;
+         case 1: /* R_MN10300_32 */
+           if (saved_sym != NULL)
+             {
+               bfd_vma value;
+
+               value = reloc->r_addend
+                 + (symtab[get_reloc_symindex (reloc->r_info)].st_value
+                    - saved_sym->st_value);
+
+               byte_put (start + reloc->r_offset, value, 4);
+
+               saved_sym = NULL;
+               return TRUE;
+             }
+           break;
+         }
+       break;
+      }
+    }
+
+  return FALSE;
+}
+
 /* Apply relocations to a debug section.  */
 
 static void
@@ -8401,11 +8450,12 @@ debug_apply_relocations (void * file,
 
          reloc_type = get_reloc_type (rp->r_info);
 
-         if (is_none_reloc (reloc_type))
+         if (target_specific_reloc_handling (rp, start, symtab))
            continue;
-
-         if (is_32bit_abs_reloc (reloc_type)
-             || is_32bit_pcrel_reloc (reloc_type))
+         else if (is_none_reloc (reloc_type))
+           continue;
+         else if (is_32bit_abs_reloc (reloc_type)
+                  || is_32bit_pcrel_reloc (reloc_type))
            reloc_size = 4;
          else if (is_64bit_abs_reloc (reloc_type)
                   || is_64bit_pcrel_reloc (reloc_type))