This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Relocate psymtab (Re: Your change breaks gdb on ld.so)


On Fri, Mar 22, 2002 at 10:41:43AM -0800, H . J . Lu wrote:
> On Fri, Mar 22, 2002 at 10:05:23AM -0800, H . J . Lu wrote:
> > 
> > Hi Jim,
> > 
> > I believe your change
> > 
> > http://sources.redhat.com/ml/gdb-patches/2001-10/msg00304.html
> > 
> > causes
> > 
> > http://sources.redhat.com/ml/gdb/2002-03/msg00155.html
> > 
> > You replaced
> > 
> > 	text_offset = pst->textlow;
> > 
> > with
> > 
> > 	text_offset = TEXTLOW (pst);
> > 
> > 
> > in read_ofile_symtab. When I did
> > 
> > # gdb gdb
> > (gdb) r /lib/ld-linux.so.2
> > (top-gdb) p *(struct symloc *)((pst)->read_symtab_private)
> > $7 = {textlow = 6208, texthigh = 18842, ldsymoff = 12, ldsymlen = 28668, 
> >   symbol_size = 12, symbol_offset = 88832, string_offset = 0, 
> >   file_string_offset = 0}
> > (top-gdb) p *pst
> > $8 = {next = 0x0, filename = 0x401f9018 "rtld.c", fullname = 0x0, 
> >   objfile = 0x823e700, section_offsets = 0x824a6b0, textlow = 2147489856, 
> >   texthigh = 2147502490, dependencies = 0x0, number_of_dependencies = 0, 
> >   globals_offset = 0, n_global_syms = 29, statics_offset = 0, 
> >   n_static_syms = 578, symtab = 0x0, 
> >   read_symtab = 0x80f74c4 <dbx_psymtab_to_symtab>, 
> >   read_symtab_private = 0x82610a8 "@\030", readin = 0 '\0'}
> > 
> > 2 textlow's aren't the same.
> > 
> 
> The problem is p->textlow and p->texthigh are adjusted in
> objfile_relocate. But your patch doesn't take that into account. As
> the result, TEXTLOW/TEXTHIGH have incorrect values.
> 
> 

Here is a patch. Any comments?


H.J.
----
2002-03-22  H.J. Lu  (hjl@gnu.org)

	* dbxread.c (dbx_relocate_psymtab): New.
	(read_dbx_dynamic_symtab): Set the relocate_psymtab field to
	dbx_relocate_psymtab.

	* objfiles.c (objfile_relocate): Call p->relocate_psymtab if
	it is not NULL.

	* symfile.c (start_psymtab_common): Initialize the
	relocate_psymtab field to NULL.

	* symtab.h (partial_symtab): Add relocate_psymtab.

--- gdb/dbxread.c.reloc	Wed Mar  6 22:30:52 2002
+++ gdb/dbxread.c	Fri Mar 22 11:05:11 2002
@@ -279,6 +279,8 @@ static void read_ofile_symtab (struct pa
 
 static void dbx_psymtab_to_symtab (struct partial_symtab *);
 
+static void dbx_relocate_psymtab (struct partial_symtab *, CORE_ADDR);
+
 static void dbx_psymtab_to_symtab_1 (struct partial_symtab *);
 
 static void read_dbx_dynamic_symtab (struct objfile *objfile);
@@ -2193,6 +2195,7 @@ start_psymtab (struct objfile *objfile, 
   TEXTHIGH (result) = result->texthigh;
   LDSYMOFF (result) = ldsymoff;
   result->read_symtab = dbx_psymtab_to_symtab;
+  result->relocate_psymtab = dbx_relocate_psymtab;
   SYMBOL_SIZE (result) = symbol_size;
   SYMBOL_OFFSET (result) = symbol_table_offset;
   STRING_OFFSET (result) = string_table_offset;
@@ -2382,6 +2385,14 @@ end_psymtab (struct partial_symtab *pst,
   return pst;
 }
 
+/* Relocate the psymtab.  */
+static void
+dbx_relocate_psymtab (struct partial_symtab *pst, CORE_ADDR offset)
+{
+  TEXTLOW (pst) += offset;
+  TEXTHIGH (pst) += offset;
+}
+
 static void
 dbx_psymtab_to_symtab_1 (struct partial_symtab *pst)
 {
--- gdb/objfiles.c.reloc	Wed Mar  6 22:31:15 2002
+++ gdb/objfiles.c	Fri Mar 22 11:00:11 2002
@@ -598,11 +598,14 @@ objfile_relocate (struct objfile *objfil
 
   {
     struct partial_symtab *p;
+    CORE_ADDR offset = ANOFFSET (delta, SECT_OFF_TEXT (objfile));
 
     ALL_OBJFILE_PSYMTABS (objfile, p)
     {
-      p->textlow += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
-      p->texthigh += ANOFFSET (delta, SECT_OFF_TEXT (objfile));
+      p->textlow += offset;
+      p->texthigh += offset;
+      if (p->relocate_psymtab)
+        p->relocate_psymtab (p, offset);
     }
   }
 
--- gdb/symfile.c.reloc	Wed Mar  6 22:31:29 2002
+++ gdb/symfile.c	Fri Mar 22 10:56:28 2002
@@ -2297,6 +2297,7 @@ start_psymtab_common (struct objfile *ob
   psymtab->texthigh = psymtab->textlow;		/* default */
   psymtab->globals_offset = global_syms - objfile->global_psymbols.list;
   psymtab->statics_offset = static_syms - objfile->static_psymbols.list;
+  psymtab->relocate_psymtab = NULL;
   return (psymtab);
 }
 
--- gdb/symtab.h.reloc	Wed Mar  6 22:31:31 2002
+++ gdb/symtab.h	Fri Mar 22 11:04:12 2002
@@ -1030,6 +1030,9 @@ struct partial_symtab
 
     void (*read_symtab) (struct partial_symtab *);
 
+    /* Pointer to function which will relocate the psymtab.  */
+    void (*relocate_psymtab) (struct partial_symtab *, CORE_ADDR);
+
     /* Information that lets read_symtab() locate the part of the symbol table
        that this psymtab corresponds to.  This information is private to the
        format-dependent symbol reading routines.  For further detail examine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]