From: Robert Plantz <plantz@sonoma.edu>
To: Scott Sibley <sisibley@gmail.com>
Cc: linux-assembly@vger.kernel.org
Subject: Re: Troubles with JIT compiler
Date: Thu, 21 Jan 2010 21:26:15 -0800 [thread overview]
Message-ID: <1264137975.1983.30.camel@bob-desktop> (raw)
In-Reply-To: <cb4d391b1001212012l654d2a93qe8d05187f8f5ecf0@mail.gmail.com>
On Thu, 2010-01-21 at 22:12 -0600, Scott Sibley wrote:
> I'm debugging a script engine. The engine compiles expressions into
> asm instructions, assigns that data to a function pointer, and
> executes the function, passing one argument.
>
> I'm new to assembly, and pretty much stuck on the first issue I ran into.
>
> Here are the function's instructions for a basic assignment operation:
>
> 0x8067990: push %ebp
> 0x8067991: mov %esp,%ebp
> 0x8067993: sub $0x8,%esp
> 0x8067999: fnstcw (%esp)
> 0x806799c: mov (%esp),%eax
> 0x806799f: or $0xc00,%eax
> 0x80679a4: mov %eax,0x4(%esp)
> 0x80679a8: fldcw 0x4(%esp)
> 0x80679ac: flds 0x806793c
> 0x80679b2: fsts 0x805f014
> 0x80679b8: fstps 0x8067954
> 0x80679be: fldcw (%esp)
> 0x80679c1: add $0x8,%esp
> 0x80679c7: emms
> 0x80679c9: leave
> 0x80679ca: ret
>
> Well, it appears to be crashing at the first instruction. Here are the
> values of ebp and esp.
>
> (gdb) x/x $ebp
> 0xbffff168: 0xbffff188
> (gdb) x/x $esp
> 0xbffff14c: 0x0804e481
>
An immediate problem I see is that the stack pointer is not properly
aligned. This is 32-bit code, and the Intel manual says that the stack
should be aligned at 32-bit addresses. That is, the least significant
digit in esp should be 0, 4, 8, or c.
I also note that the values in ebp and esp are very far apart.
Typically, they contain similar values -- addresses somewhere in the
stack.
I would look at how the stack was set up in this program.
--Bob
next prev parent reply other threads:[~2010-01-22 5:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-22 4:12 Troubles with JIT compiler Scott Sibley
2010-01-22 5:26 ` Robert Plantz [this message]
2010-01-22 6:04 ` Scott Sibley
2010-01-22 7:01 ` Robert Plantz
2010-01-22 7:16 ` Scott Sibley
2010-01-22 10:45 ` Scott Sibley
2010-01-22 16:50 ` Robert Plantz
2010-01-22 17:19 ` Brian Raiter
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=1264137975.1983.30.camel@bob-desktop \
--to=plantz@sonoma.edu \
--cc=linux-assembly@vger.kernel.org \
--cc=sisibley@gmail.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