All of lore.kernel.org
 help / color / mirror / Atom feed
From: Blake McBride <blake@arahant.com>
To: linux-assembly@vger.kernel.org
Subject: Re: Need help doing a jmp rather than a call
Date: Sat, 9 Nov 2013 10:19:52 -0600	[thread overview]
Message-ID: <l5lnau$mpa$1@ger.gmane.org> (raw)
In-Reply-To: 20131109144246.GD5152@jeffraw

On 2013-11-09 08:42:46 -0600, Rob said:

> On Sat, Nov 09, 2013 at 08:13:13AM -0600, Blake McBride wrote:
> 
> So forget that, the other approach is to manually forward the registers.
> This is roughly what optimised disassembly of the above forward function
> would look like, if you got gcc to tail-call and not do any frame setup.
> 
> .globl forward
> forward:
> 	// any free register that's not preserved across calls
> 	movq %rdi, %r10
> 
> 	// forward call registers
> 	movq %rsi, %rdi
> 	movq %rdx, %rsi
> 	movq %rcx, %rdx
> 	movq %r8, %rdx
> 	movq %r9, %r8
> 
> 	// return address is at (%rsp), so we can just jump
> 	jmp *%r10
> 
> 
> HTH,
> Rob


I corrected your small %rdx typo above and tried the following.  It 
doesn't work either though.  Knowing what I know now though, you must 
be close.

.globl __jumpToMethod
__jumpToMethod:
LFB2:
	pushq	%rbp
LCFI0:
	movq	%rsp, %rbp
LCFI1:
	movl	$0, %eax
//	call	*%rdi
//	leave
//	ret
	// any free register that's not preserved across calls
	movq %rdi, %r10

	// forward call registers
	movq %rsi, %rdi
	movq %rdx, %rsi
	movq %rcx, %rdx
	movq %r8, %rcx
	movq %r9, %r8

	// return address is at (%rsp), so we can just jump
	jmp *%r10




  reply	other threads:[~2013-11-09 16:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-09  3:02 Need help doing a jmp rather than a call Blake McBride
2013-11-09  6:19 ` Sofiane Akermoun
2013-11-09  8:21   ` Blake McBride
2013-11-09 10:57     ` Sofiane Akermoun
2013-11-09 11:00       ` Sofiane Akermoun
2013-11-09 14:13         ` Blake McBride
2013-11-09 14:42           ` Rob
2013-11-09 16:19             ` Blake McBride [this message]
2013-11-09 21:30               ` Rob
2013-11-09 22:47                 ` Blake McBride
2013-11-10  0:01                   ` Blake McBride

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='l5lnau$mpa$1@ger.gmane.org' \
    --to=blake@arahant.com \
    --cc=linux-assembly@vger.kernel.org \
    /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.