Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: "Maciej W. Rozycki" <macro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] gdbserver: Handle DT_MIPS_RLD_MAP dynamic tag
Date: Tue, 03 Apr 2012 21:27:00 -0000	[thread overview]
Message-ID: <4F7B6B31.3010203@redhat.com> (raw)
In-Reply-To: <alpine.DEB.1.10.1204031401130.19835@tp.orcam.me.uk>

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


  reply	other threads:[~2012-04-03 21:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-03 20:48 Maciej W. Rozycki
2012-04-03 21:27 ` Pedro Alves [this message]
2012-04-04 11:37   ` Maciej W. Rozycki
2012-04-04 11:55     ` Pedro Alves
2012-04-10 22:54       ` Maciej W. Rozycki
2012-04-04 19:16 ` Jan Kratochvil

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F7B6B31.3010203@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox