This is the mail archive of the gdb-patches@sourceware.org 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]

Re: Shared library call problems on PowerPC with current binutils/gdb


On Mon, Apr 28, 2008 at 08:39:51PM -0400, Daniel Jacobowitz wrote:
> On Tue, Apr 29, 2008 at 12:53:58AM +0200, Ulrich Weigand wrote:
> > - Extend elf_symtab_read to treat a synthetic symbol XXX@plt as a
> >   mst_solib_trampoline symbol for XXX.
> 
> Sounds reasonable.  I suggested this to Aleksandar for another
> problem, even :-) Though it was kind of nice to have it show up in
> disassembly with @plt; will it still do that?  It's nice to know
> immediately when I'm looking at the PLT stub instead of the
> definition.

This appears to work consistently, where by work I mean disassembly
shows the @plt sym but breakpoints on the undecorated version work
fine.  I'm not sure exactly why; it may be luck.  If it's luck
and someone cares later, we could make it work reliably by making
sure the @plt version has an accurate size and the non-@plt version
has size 0, or by making lookup_minimal_symbol_by_pc_section
explicitly prefer text to non-text symbols.

Hmm, thinking about this more, it probably won't work for your
case after all.  lookup_solib_trampoline_symbol_by_pc will return
NULL if the first symbol we find is the text version.

What do you think?  I wrote this because I need it to get some symbol
for malloc on Symbian, where I do not have a symbol file corresponding
to libc.  The PLT entry works nicely for that purpose.

-- 
Daniel Jacobowitz
CodeSourcery

2008-05-02  Daniel Jacobowitz  <dan@codesourcery.com>

	* elfread.c (elf_symtab_read): Create trampolines for @plt symbols.

Index: symbian-fsf/gdb/elfread.c
===================================================================
--- symbian-fsf.orig/gdb/elfread.c	2008-05-02 16:56:20.000000000 -0400
+++ symbian-fsf/gdb/elfread.c	2008-05-02 17:34:42.000000000 -0400
@@ -521,6 +521,33 @@ elf_symtab_read (struct objfile *objfile
 	  if (msym != NULL)
 	    msym->filename = filesymname;
 	  gdbarch_elf_make_msymbol_special (gdbarch, sym, msym);
+
+	  /* For @plt symbols, also record a trampoline to the
+	     destination symbol.  The @plt symbol will be used in
+	     disassembly, and the trampoline will be used when we are
+	     trying to find the target.  */
+	  if (msym && ms_type == mst_text && type == ST_SYNTHETIC)
+	    {
+	      int len = strlen (sym->name);
+
+	      if (len > 4 && strcmp (sym->name + len - 4, "@plt") == 0)
+		{
+		  char *base_name = alloca (len - 4 + 1);
+		  struct minimal_symbol *mtramp;
+
+		  memcpy (base_name, sym->name, len - 4);
+		  base_name[len - 4] = '\0';
+		  mtramp = record_minimal_symbol (base_name, symaddr,
+						  mst_solib_trampoline,
+						  sym->section, objfile);
+		  if (mtramp)
+		    {
+		      MSYMBOL_SIZE (mtramp) = MSYMBOL_SIZE (msym);
+		      mtramp->filename = filesymname;
+		      gdbarch_elf_make_msymbol_special (gdbarch, sym, mtramp);
+		    }
+		}
+	    }
 	}
     }
 }


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