From mboxrd@z Thu Jan 1 00:00:00 1970 From: Blake McBride Subject: Re: Need help doing a jmp rather than a call Date: Sat, 9 Nov 2013 10:19:52 -0600 Message-ID: References: <20131109144246.GD5152@jeffraw> Mime-Version: 1.0 Content-Transfer-Encoding: 7BIT Return-path: Sender: linux-assembly-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: linux-assembly@vger.kernel.org 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