All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Ulrich Drepper <drepper@redhat.com>
Cc: Linus Torvalds <torvalds@transmeta.com>,
	Andrew Morton <akpm@digeo.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: unwinding for vsyscall code
Date: Sun, 13 Apr 2003 14:10:28 -0700	[thread overview]
Message-ID: <20030413141028.A3683@twiddle.net> (raw)
In-Reply-To: <3E98E01C.3070103@redhat.com>; from drepper@redhat.com on Sat, Apr 12, 2003 at 08:57:16PM -0700

On Sat, Apr 12, 2003 at 08:57:16PM -0700, Ulrich Drepper wrote:
> +	/* What follows are the instructions for the table generation.
> +	   We have to record all changes of the stack pointer.  */
> +		0x04,			/* DW_CFA_advance_loc4 */
> +		0x01, 0x00, 0x00, 0x00,	/* Size of push %ecx */
> +		0x0e,			/* DW_CFA_def_cfa_offset */
> +		0x08,			/* RA at offset 8 now */
> +		0x04,			/* DW_CFA_advance_loc4 */
> +		0x01, 0x00, 0x00, 0x00,	/* Size of push %edx */
> +		0x0e,			/* DW_CFA_def_cfa_offset */
> +		0x0c,			/* RA at offset 12 now */
> +		0x04,			/* DW_CFA_advance_loc4 */
> +		0x01, 0x00, 0x00, 0x00,	/* Size of push %ebp */
> +		0x0e,			/* DW_CFA_def_cfa_offset */
> +		0x10,			/* RA at offset 16 now */

Not only changes to the stack pointer, but also changes to call-saved
registers, such as %ebp.  You're intending to be able to unwind through
asynchronous signals here, which means that you can't leave even a single
insn window with a register modified but not recorded.

So you also need a

	0x85 0x04			DW_CFA_offset %ebp -16

there at the end of the prologue.

> +	/* Finally the epilogue.  */
> +		0x04,			/* DW_CFA_advance_loc4 */
> +		0x0e, 0x00, 0x00, 0x00,	/* Offset til pop %edx */
> +		0x0e,			/* DW_CFA_def_cfa_offset */
> +		0x12,			/* RA at offset 12 now */

And of course you need a corresponding bit here, since once we
pop off the slot in which we stored %ebp, we can't restore it
from there, because we will have clobbered that slot in the
signal handler.

(Btw, typo here in comment; it's "%ebp" not "%edx".)

So here we also need a 

	0xc5				DW_CFA_restore %ebp

here before the next DW_CFA_advance_loc.

Oh, and you don't need to use DW_CFA_advance_loc4.  You should
be using

	DW_CFA_advance_loc+N		N <= 0x3f
	DW_CFA_advance_loc1 N		N <= 0xff

We have to use DW_CFA_advance_loc4 in GCC because we don't know
the true sizes of instructions.  This gets fixed for us in GAS
through some truely disgusting magic based on section names.



r~

  reply	other threads:[~2003-04-13 20:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-13  3:57 unwinding for vsyscall code Ulrich Drepper
2003-04-13 21:10 ` Richard Henderson [this message]
2003-04-13 22:35   ` Ulrich Drepper
2003-04-14 23:05     ` Richard Henderson

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=20030413141028.A3683@twiddle.net \
    --to=rth@twiddle.net \
    --cc=akpm@digeo.com \
    --cc=drepper@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.