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: [PATCH] gdbserver: Handle DT_MIPS_RLD_MAP dynamic tag


Hi Maciej,

On 04/03/2012 09:47 PM, Maciej W. Rozycki wrote:

>  While working on a test case for an unrelated issue I have noticed 
> single-stepping over system library calls is broken on the MIPS/Linux 
> target when `gdbserver' is used.  On closer inspection I have observed 
> `gdbserver' reports no shared libraries loaded.  Further investigation has 
> revealed that the newly-added support for the `qXfer:libraries-svr4:read' 
> packet does not handle the DT_MIPS_RLD_MAP dynamic tag and therefore 
> cannot locate the link map on the MIPS target.


Yeah, I had noticed that on
<http://sourceware.org/ml/gdb-patches/2012-03/msg00142.html>, but never got
to propose a fix.  Sorry about that.


> gdb-gdbserver-rld-map.diff

> Index: gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c
> ===================================================================
> --- gdb-fsf-trunk-quilt.orig/gdb/gdbserver/linux-low.c	2012-04-03 13:38:58.575561428 +0100
> +++ gdb-fsf-trunk-quilt/gdb/gdbserver/linux-low.c	2012-04-03 13:39:17.315624148 +0100
> @@ -5419,7 +5419,9 @@ get_dynamic (const int pid, const int is
>  }
>  
>  /* Return &_r_debug in the inferior, or -1 if not present.  Return value
> -   can be 0 if the inferior does not yet have the library list initialized.  */
> +   can be 0 if the inferior does not yet have the library list initialized.
> +   We look for DT_MIPS_RLD_MAP first.  MIPS executables use this instead of
> +   DT_DEBUG, although they sometimes contain an unused DT_DEBUG entry too.  */

>

Can that "unused DT_DEBUG" entry ever appear before DT_MIPS_RLD_MAP in the tags
list?  With this patch, we'll stop looking if we see DT_DEBUG first, while
solib-svr4.c in GDB first looks for DT_MIPS_RLD_MAP in all tags, and only
if not found looks for DT_DEBUG (presumably, if there's no DT_MIPS_RLD_MAP,
then there's no DT_DEBUG either; only if DT_MIPS_RLD_MAP exist might there be
a DT_DEBUG).  Do we need to worry about this?

>  static CORE_ADDR
>  get_r_debug (const int pid, const int is_elf64)
> @@ -5437,6 +5439,21 @@ get_r_debug (const int pid, const int is
>        if (is_elf64)
>  	{
>  	  Elf64_Dyn *const dyn = (Elf64_Dyn *) buf;
> +	  union
> +	    {
> +	      Elf64_Xword map;
> +	      unsigned char buf[sizeof (Elf64_Xword)];
> +	    }
> +	  rld_map;
> +
> +	  if (dyn->d_tag == DT_MIPS_RLD_MAP)
> +	    {
> +	      if (linux_read_memory (dyn->d_un.d_val,
> +				     rld_map.buf, sizeof (rld_map.buf)) == 0)
> +		return rld_map.map;
> +	      else
> +		break;
> +	    }
>  
>  	  if (dyn->d_tag == DT_DEBUG)
>  	    return dyn->d_un.d_val;
> @@ -5447,6 +5464,21 @@ get_r_debug (const int pid, const int is
>        else
>  	{
>  	  Elf32_Dyn *const dyn = (Elf32_Dyn *) buf;
> +	  union
> +	    {
> +	      Elf32_Word map;
> +	      unsigned char buf[sizeof (Elf32_Word)];
> +	    }
> +	  rld_map;
> +
> +	  if (dyn->d_tag == DT_MIPS_RLD_MAP)
> +	    {
> +	      if (linux_read_memory (dyn->d_un.d_val,
> +				     rld_map.buf, sizeof (rld_map.buf)) == 0)
> +		return rld_map.map;
> +	      else
> +		break;
> +	    }
>  
>  	  if (dyn->d_tag == DT_DEBUG)
>  	    return dyn->d_un.d_val;



-- 
Pedro Alves


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