From: Paolo Ornati <ornati@fastwebnet.it>
To: Lethalman <lethalman@fyrebird.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Let me know EIP address
Date: Tue, 4 Jan 2005 17:10:43 +0100 [thread overview]
Message-ID: <20050104171043.21c7c4ef@tux.homenet> (raw)
In-Reply-To: <41DAB3AA.4010207@fyrebird.net>
On Tue, 04 Jan 2005 16:18:02 +0100
Lethalman <lethalman@fyrebird.net> wrote:
> I'm trying to get the EIP value from a simple program in C but i don't
> how to do it. I need it to know the current address position on the
> code segment.
>
> main() {
> long *eip;
> asm("mov %%eip,%0" : "=g"(eip));
> printf("%p\n", eip);
> }
>
> Unfortunately EIP is not that kind of register :P
> Does anyone know how to get EIP?
IA-32 Intel® Architecture
Software Developer's
Manual
Volume 1:
Basic Architecture
3.5. INSTRUCTION POINTER
[...]
The EIP register cannot be accessed directly by software; it is
controlled implicitly by control- transfer instructions (such as JMP,
Jcc, CALL, and RET), interrupts, and exceptions. The only way to read
the EIP register is to execute a CALL instruction and then read the
value of the return instruction pointer from the procedure stack. The
EIP register can be loaded indirectly by modifying the value of a return
instruction pointer on the procedure stack and executing a return
instruction (RET or IRET). See Section 6.2.4.2., "Return Instruction
Pointer".
[...]
--
Paolo Ornati
Gentoo Linux (kernel 2.6.10-cko2)
next prev parent reply other threads:[~2005-01-04 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-04 15:18 Let me know EIP address Lethalman
2005-01-04 16:05 ` linux-os
2005-01-04 16:21 ` Paulo Marques
2005-01-04 16:10 ` Paolo Ornati [this message]
2005-01-04 17:50 ` Bernd Eckenfels
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=20050104171043.21c7c4ef@tux.homenet \
--to=ornati@fastwebnet.it \
--cc=lethalman@fyrebird.net \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox