2010-02-03 Tristan Gingold <gingold@adacore.com>
authorTristan Gingold <gingold@adacore.com>
Wed, 3 Feb 2010 14:13:16 +0000 (14:13 +0000)
committerTristan Gingold <gingold@adacore.com>
Wed, 3 Feb 2010 14:13:16 +0000 (14:13 +0000)
* symfile.h (struct sym_fns): Add sym_relocate field.
(default_symfile_relocate): New prototype.
(symfile_relocate_debug_section): First argument is now an objfile.
* symfile.c (default_symfile_relocate): Rename from
symfile_relocate_debug_section, first argument is now an objfile.
(symfile_relocate_debug_section): New function.
* coffread.c (coff_sym_fns): Set sym_relocate field.
* somread.c (som_sym_fns): Ditto.
* mipsread.c (ecoff_sym_fns): Ditto.
* machoread.c (macho_sym_fns): Ditto.
* elfread.c (elf_sym_fns): Ditto.
* dwarf2read.c (dwarf2_read_section): Ditto.
* xcoffread.c (xcoff_sym_fns): Ditto.
* dbxread.c (aout_sym_fns): Ditto.
(dbx_psymtab_to_symtab): Adjust call to symfile_relocate_debug_section.
(elfstab_build_psymtabs): Ditto.

gdb/ChangeLog
gdb/coffread.c
gdb/dbxread.c
gdb/dwarf2read.c
gdb/elfread.c
gdb/machoread.c
gdb/mipsread.c
gdb/somread.c
gdb/symfile.c
gdb/symfile.h
gdb/xcoffread.c

index 52886a8fad5ea10e230433ec1632e52e55f486fa..fb0ea02d32bc3d44dc30062b4cec6b2101971e68 100644 (file)
@@ -1,3 +1,22 @@
+2010-02-03  Tristan Gingold  <gingold@adacore.com>
+
+       * symfile.h (struct sym_fns): Add sym_relocate field.
+       (default_symfile_relocate): New prototype.
+       (symfile_relocate_debug_section): First argument is now an objfile.
+       * symfile.c (default_symfile_relocate): Rename from
+       symfile_relocate_debug_section, first argument is now an objfile.
+       (symfile_relocate_debug_section): New function.
+       * coffread.c (coff_sym_fns): Set sym_relocate field.
+       * somread.c (som_sym_fns): Ditto.
+       * mipsread.c (ecoff_sym_fns): Ditto.
+       * machoread.c (macho_sym_fns): Ditto.
+       * elfread.c (elf_sym_fns): Ditto.
+       * dwarf2read.c (dwarf2_read_section): Ditto.
+       * xcoffread.c (xcoff_sym_fns): Ditto.
+       * dbxread.c (aout_sym_fns): Ditto.
+       (dbx_psymtab_to_symtab): Adjust call to symfile_relocate_debug_section.
+       (elfstab_build_psymtabs): Ditto.
+
 2010-02-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        * defs.h (MAX_REGISTER_SIZE): Increase to 32.
index 8e5dca9960431f210e9ec2792d2ba8be801b0186..ba413ade3658d1b51f8705453e8151c791ec8842 100644 (file)
@@ -2128,6 +2128,7 @@ static struct sym_fns coff_sym_fns =
   default_symfile_segments,    /* sym_segments: Get segment information from
                                   a file.  */
   NULL,                         /* sym_read_linetable  */
+  default_symfile_relocate,    /* sym_relocate: Relocate a debug section.  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
index 6ef676735e4a63726c5dbefa457378d6674ef5aa..c9a575477fbafd8501822c06c1035dbf9012a788 100644 (file)
@@ -2473,7 +2473,7 @@ Shouldn't happen.\n",
       if (DBX_STAB_SECTION (pst->objfile))
        {
          stabs_data
-           = symfile_relocate_debug_section (pst->objfile->obfd,
+           = symfile_relocate_debug_section (pst->objfile,
                                              DBX_STAB_SECTION (pst->objfile),
                                              NULL);
          if (stabs_data)
@@ -3460,7 +3460,7 @@ elfstab_build_psymtabs (struct objfile *objfile, asection *stabsect,
 
   symbuf_read = 0;
   symbuf_left = bfd_section_size (objfile->obfd, stabsect);
-  stabs_data = symfile_relocate_debug_section (objfile->obfd, stabsect, NULL);
+  stabs_data = symfile_relocate_debug_section (objfile, stabsect, NULL);
   if (stabs_data)
     back_to = make_cleanup (free_current_contents, (void *) &stabs_data);
 
@@ -3571,6 +3571,7 @@ static struct sym_fns aout_sym_fns =
   default_symfile_segments,    /* sym_segments: Get segment information from
                                   a file.  */
   NULL,                         /* sym_read_linetable */
+  default_symfile_relocate,    /* sym_relocate: Relocate a debug section.  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
index 86bfecb236e1658f5d68d8fa0d91c480e4af1540..0dc1b11d78e2f2c8ee333517586561cb2feaab63 100644 (file)
@@ -1412,7 +1412,7 @@ dwarf2_read_section (struct objfile *objfile, struct dwarf2_section_info *info)
      http://sourceware.org/ml/gdb-patches/2002-04/msg00136.html .
      We never compress sections in .o files, so we only need to
      try this when the section is not compressed.  */
-  retbuf = symfile_relocate_debug_section (abfd, sectp, buf);
+  retbuf = symfile_relocate_debug_section (objfile, sectp, buf);
   if (retbuf != NULL)
     {
       info->buffer = retbuf;
index 78e916360022110cb0b1160148c3c72f000eb372..9a2a1e3bd820c9df7411b48f99ad5ca22a61ce41 100644 (file)
@@ -1057,6 +1057,7 @@ static struct sym_fns elf_sym_fns =
   elf_symfile_segments,                /* sym_segments: Get segment information from
                                   a file.  */
   NULL,                         /* sym_read_linetable */
+  default_symfile_relocate,    /* sym_relocate: Relocate a debug section.  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
index 02b61d3adcf2cb5b03c06753e610a437873fee59..be9e2a571333ebdafa97ce1651f492137f20716b 100644 (file)
@@ -759,6 +759,9 @@ static struct sym_fns macho_sym_fns = {
   macho_symfile_offsets,        /* sym_offsets:  xlate external to internal form */
   default_symfile_segments,    /* sym_segments: Get segment information from
                                   a file.  */
+  NULL,                         /* sym_read_linetable */
+  default_symfile_relocate,    /* sym_relocate: Relocate a debug section.  */
+
   NULL                          /* next: pointer to next struct sym_fns */
 };
 
index 4ef817e2f0dab353a5b5f05060dd8f58f8e6ca8a..093313e68eb494fb45438c18223d0a1e86f6c81b 100644 (file)
@@ -399,6 +399,7 @@ static struct sym_fns ecoff_sym_fns =
   default_symfile_segments,    /* sym_segments: Get segment information from
                                   a file.  */
   NULL,                         /* sym_read_linetable */
+  default_symfile_relocate,    /* sym_relocate: Relocate a debug section.  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
index c7beaba6f1b733a0e835d471eb0f038c272d7e67..3d93c5ee2a881ce6c5bb252214eb65c790bde5cc 100644 (file)
@@ -437,6 +437,7 @@ static struct sym_fns som_sym_fns =
   default_symfile_segments,    /* sym_segments: Get segment information from
                                   a file.  */
   NULL,                         /* sym_read_linetable */
+  default_symfile_relocate,    /* sym_relocate: Relocate a debug section.  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
index bc5240691c32bd9f5aa51d36f4cb77d9ff49235f..efa341dfe32d7127180b73f0a52a116bbc6e9b28 100644 (file)
@@ -3627,6 +3627,27 @@ symfile_dummy_outputs (bfd *abfd, asection *sectp, void *dummy)
   sectp->output_offset = 0;
 }
 
+/* Default implementation for sym_relocate.  */
+
+
+bfd_byte *
+default_symfile_relocate (struct objfile *objfile, asection *sectp,
+                          bfd_byte *buf)
+{
+  bfd *abfd = objfile->obfd;
+
+  /* We're only interested in sections with relocation
+     information.  */
+  if ((sectp->flags & SEC_RELOC) == 0)
+    return NULL;
+
+  /* We will handle section offsets properly elsewhere, so relocate as if
+     all sections begin at 0.  */
+  bfd_map_over_sections (abfd, symfile_dummy_outputs, NULL);
+
+  return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
+}
+
 /* Relocate the contents of a debug section SECTP in ABFD.  The
    contents are stored in BUF if it is non-NULL, or returned in a
    malloc'd buffer otherwise.
@@ -3642,18 +3663,12 @@ symfile_dummy_outputs (bfd *abfd, asection *sectp, void *dummy)
    debug section.  */
 
 bfd_byte *
-symfile_relocate_debug_section (bfd *abfd, asection *sectp, bfd_byte *buf)
+symfile_relocate_debug_section (struct objfile *objfile,
+                                asection *sectp, bfd_byte *buf)
 {
-  /* We're only interested in sections with relocation
-     information.  */
-  if ((sectp->flags & SEC_RELOC) == 0)
-    return NULL;
-
-  /* We will handle section offsets properly elsewhere, so relocate as if
-     all sections begin at 0.  */
-  bfd_map_over_sections (abfd, symfile_dummy_outputs, NULL);
+  gdb_assert (objfile->sf->sym_relocate);
 
-  return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
+  return (*objfile->sf->sym_relocate) (objfile, sectp, buf);
 }
 
 struct symfile_segment_data *
index efa069e1485687fc8ca3ba57da1cbe88310257c8..302c29f60287c0e38104f63d8f0fb7c26c1ff292 100644 (file)
@@ -163,8 +163,15 @@ struct sym_fns
   /* This function should read the linetable from the objfile when
      the line table cannot be read while processing the debugging
      information.  */
+
   void (*sym_read_linetable) (void);
 
+  /* Relocate the contents of a debug section SECTP.  The
+     contents are stored in BUF if it is non-NULL, or returned in a
+     malloc'd buffer otherwise.  */
+
+  bfd_byte *(*sym_relocate) (struct objfile *, asection *sectp, bfd_byte *buf);
+
   /* Finds the next struct sym_fns.  They are allocated and
      initialized in whatever module implements the functions pointed
      to; an initializer calls add_symtab_fns to add them to the global
@@ -195,6 +202,12 @@ extern void default_symfile_offsets (struct objfile *objfile,
 
 extern struct symfile_segment_data *default_symfile_segments (bfd *abfd);
 
+/* The default version of sym_fns.sym_relocate for readers that don't
+   do anything special.  */
+
+extern bfd_byte *default_symfile_relocate (struct objfile *objfile,
+                                           asection *sectp, bfd_byte *buf);
+
 extern void extend_psymbol_list (struct psymbol_allocation_list *,
                                 struct objfile *);
 
@@ -374,8 +387,8 @@ extern void symbol_file_clear (int from_tty);
 /* Default overlay update function.  */
 extern void simple_overlay_update (struct obj_section *);
 
-extern bfd_byte *symfile_relocate_debug_section (bfd *abfd, asection *sectp,
-                                                bfd_byte * buf);
+extern bfd_byte *symfile_relocate_debug_section (struct objfile *, asection *,
+                                                bfd_byte *);
 
 extern int symfile_map_offsets_to_segments (bfd *,
                                            struct symfile_segment_data *,
index 25cc2d992ddfc6f76b44041ffff2972fe1921dc0..acd7b50ae48dfaab6f26cd705afc85f09d8666f1 100644 (file)
@@ -3035,6 +3035,7 @@ static struct sym_fns xcoff_sym_fns =
   default_symfile_segments,    /* sym_segments: Get segment information from
                                   a file.  */
   aix_process_linenos,          /* sym_read_linetable */
+  default_symfile_relocate,    /* sym_relocate: Relocate a debug section.  */
   NULL                         /* next: pointer to next struct sym_fns */
 };
 
This page took 0.037651 seconds and 4 git commands to generate.