[lkml]   [2005]   [Jan]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Let me know EIP address
linux-os wrote:
> On Tue, 4 Jan 2005, Lethalman 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?
> You get the offset of a label, i.e., "foo:\t movl $foo,%0\n" in the asm
> code.

Or use a gcc extension, so that you don't have to write assembly code:

int main(int argc, char *argv[])
printf("this is my address %p\n", &&address);
return 0;

Paulo Marques -

"A journey of a thousand miles begins with a single step."
Lao-tzu, The Way of Lao-tzu

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 14:09    [W:0.298 / U:0.448 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site