From: Jun Koi <junkoi2004@gmail.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: Question on implementatio of GETPC()
Date: Wed, 28 Apr 2010 17:29:31 +0900 [thread overview]
Message-ID: <m2xfdaac4d51004280129rb21ed6acn46c422510d19a4f3@mail.gmail.com> (raw)
In-Reply-To: <4BD7EDFA.9010102@siemens.com>
On Wed, Apr 28, 2010 at 5:12 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> Jun Koi wrote:
>> Hi,
>>
>> In x86, GETPC() is implemented as below:
>>
>> # define GETPC() ((void *)((unsigned long)__builtin_return_address(0) - 1))
>>
>> As I understand, it gets the returned address on the stack, then
>> subtract 1 to get back to the above address.
>>
>> Imagine we have code like this (pseudo asm code):
>>
>> ....
>> CALL <relative address>
>> <next-insn>
>> ....
>>
>> When we call GETPC, we get the address of <next-insn>, and subtract 1.
>> But the problem is that the CALL insn is more than 1 byte, so how can
>> GETPC() gives us the address of the CALL insn above?
>>
>> I guess I must misunderstood something here ....
>
> IIRC, the result of GETPC is used for a range check. So you just have to
> ensure that it points somewhere into the translated code sequence of the
> current target instruction.
>
Hmm if I am not wrong, the GETPC address is really used as jump target
of some code (such as when handling page fault), so that must be
accurate.
This is so confused to me!
Thanks,
J
next prev parent reply other threads:[~2010-04-28 8:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-28 4:51 [Qemu-devel] Question on implementatio of GETPC() Jun Koi
2010-04-28 8:12 ` [Qemu-devel] " Jan Kiszka
2010-04-28 8:29 ` Jun Koi [this message]
2010-04-28 10:41 ` Jan Kiszka
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=m2xfdaac4d51004280129rb21ed6acn46c422510d19a4f3@mail.gmail.com \
--to=junkoi2004@gmail.com \
--cc=jan.kiszka@siemens.com \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).