Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Mark Kettenis <mark.kettenis@xs4all.nl>
To: macro@codesourcery.com
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] microMIPS support (Linux signal trampolines)
Date: Fri, 18 May 2012 22:25:00 -0000	[thread overview]
Message-ID: <201205182225.q4IMPBiD031110@glazunov.sibelius.xs4all.nl> (raw)
In-Reply-To: <alpine.DEB.1.10.1205171611090.11227@tp.orcam.me.uk>	(macro@codesourcery.com)

> Date: Fri, 18 May 2012 22:31:45 +0100
> From: "Maciej W. Rozycki" <macro@codesourcery.com>
>
>  To see if we need to check whether the execution mode selected matches 
> the given trampoline I have checked what the bit patterns of all the 
> trampoline sequences decode to in the opposite instruction set.  This 
> produced useless or at least unusual code in most cases, for example:
> 
> microMIPS/EB, o32 sigreturn, decoded as MIPS:
> 	30401017 	andi	zero,v0,0x1017
> 	00008b7c 	dsll32	s1,zero,0xd
> 
> MIPS/EL, o32 sigreturn, decoded as microMIPS:
> 	1017 2402 	addi	zero,s7,9218
> 	000c 0000 	sll	zero,t0,0x0
> 
> However in some corner cases reasonable code can mimic a trampoline, for 
> example:
> 
> MIPS/EB, n32 rt_sigreturn, decoded as microMIPS:
> 	2402      	sll	s0,s0,1
> 	1843 0000 	sb	v0,0(v1)
> 	000c 0f3c 	jr	t0
> 
> -- here the first instruction is a 16-bit one making things nastier even 
> as there are some other microMIPS instructions whose first 16-bit halfword 
> is 0x000c and therefore matches this whole trampoline pattern.

On some OSes the signal trampolines are guaranteed to have a certain
alignment.  Is that the case for MIPS Linux as well perhaps?  Or would
that not help you?

> Index: gdb-fsf-trunk-quilt/gdb/tramp-frame.c
> ===================================================================
> --- gdb-fsf-trunk-quilt.orig/gdb/tramp-frame.c	2012-02-24 15:23:42.000000000 +0000
> +++ gdb-fsf-trunk-quilt/gdb/tramp-frame.c	2012-05-18 20:03:53.775469792 +0100
> @@ -87,6 +87,12 @@ tramp_frame_start (const struct tramp_fr
>    enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
>    int ti;
>  
> +  /* Check if we can use this trampoline.  */
> +  if (tramp->validate)
> +    pc = tramp->validate (tramp, this_frame, pc);
> +  if (pc == 0)
> +    return 0;

I suppose chances are small we'll ever have a platform with
trampolines at address 0, but nevertheless, wouldn't it be more
correct to write

  if (tramp->validate)
    {
      pc = tramp->validate (tramp, this_frame, pc);
      if (pc == 0)
        return 0;
    }

as you're checking for the magic return value?


  reply	other threads:[~2012-05-18 22:25 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-24 21:18 [PATCH] microMIPS support Maciej W. Rozycki
2012-04-25  6:20 ` Eli Zaretskii
2012-04-26 13:54   ` Maciej W. Rozycki
2012-04-26 14:14     ` Eli Zaretskii
2012-04-26 18:03       ` Maciej W. Rozycki
2012-04-26 20:39         ` Eli Zaretskii
2012-04-27 18:16           ` Maciej W. Rozycki
2012-04-27 18:24             ` Eli Zaretskii
     [not found]               ` <alpine.DEB.1.10.1204302334520.19835@tp.orcam.me.uk>
2012-05-02 16:39                 ` Eli Zaretskii
2012-05-17 15:07                   ` Maciej W. Rozycki
2012-05-17 16:10                     ` Eli Zaretskii
2012-05-18 23:13                       ` Maciej W. Rozycki
2012-05-19  8:20                         ` Eli Zaretskii
2012-04-25 13:13 ` Yao Qi
2012-04-25 15:57   ` Maciej W. Rozycki
2012-04-25 15:54 ` Joel Brobecker
2012-04-25 17:18   ` Maciej W. Rozycki
2012-04-25 18:12     ` Joel Brobecker
2012-04-25 18:27       ` Maciej W. Rozycki
2012-04-26 18:38 ` Jan Kratochvil
2012-04-26 19:04   ` Maciej W. Rozycki
2012-04-26 19:29     ` Jan Kratochvil
2012-04-26 21:59       ` Maciej W. Rozycki
2012-04-27  7:11         ` Jan Kratochvil
2012-04-27 15:14           ` Maciej W. Rozycki
2012-04-27 15:29             ` Pedro Alves
2012-04-27 15:46               ` Maciej W. Rozycki
2012-04-27 15:54             ` Tom Tromey
2012-05-18 23:53     ` Maciej W. Rozycki
2012-05-18 21:32 ` [PATCH] microMIPS support (Linux signal trampolines) Maciej W. Rozycki
2012-05-18 22:25   ` Mark Kettenis [this message]
2012-05-21 14:33     ` Maciej W. Rozycki
2012-06-11 10:32       ` [PING][PATCH] " Maciej W. Rozycki
2014-09-28 11:12       ` [PATCH] " Maciej W. Rozycki
2014-10-06  0:46         ` [PING][PATCH] " Maciej W. Rozycki
2014-10-13 12:24           ` [PING^2][PATCH] " Maciej W. Rozycki
2014-10-20 17:01             ` [PING^3][PATCH] " Maciej W. Rozycki
2014-11-03 16:04               ` [PING^4][PATCH] " Maciej W. Rozycki
2014-11-16  8:58         ` [PATCH] " Joel Brobecker
2014-12-03 21:00           ` Maciej W. Rozycki
2012-05-18 23:47 ` [PATCH] microMIPS support Maciej W. Rozycki
2012-05-19  8:52   ` Eli Zaretskii
2012-05-22  0:07     ` Maciej W. Rozycki

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=201205182225.q4IMPBiD031110@glazunov.sibelius.xs4all.nl \
    --to=mark.kettenis@xs4all.nl \
    --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