[C/C++] Getting return address…

Language/C&C++ 2010.11.03 15:43

Very simple... Just describing here for me to remind.

=== ARM(32bit) - RVCT ===
/* #pragma O0 <- due to optimized out, this may be required */
{ /* Just Scope */
    void* ra;
    /* register lr(r14) has return address */
    __asm
    { mov ra, lr }
    /* now variable 'ra' has return address */
}

=== x86(32bit) - GCC ===
{ /* Just Scope */
    register void* ra; /* return address */
    /* return address is stored at 4byte above from 'ebp' */
    asm ("movl 4(%%ebp), %0;"
         :"=r"(ra));
    /* now variable 'ra' has return address */
}
신고

'Language > C&C++' 카테고리의 다른 글

[C/C++] Encapsulation tip in C.  (0) 2010.11.12
[C/C++] Tips and Memos  (0) 2010.11.12
[C/C++] Getting return address…  (0) 2010.11.03
[Linux][C/C++] Understanding Signals – User Signal Handler  (0) 2010.10.29
[C/C++] type of hard-coded-string.  (0) 2010.09.16
[C/C++] Function pointer.  (0) 2010.05.24
Trackback 0 : Comment 0