Re: Exception Handling

"jacob navia" <jacob@jacob.remcomp.fr>
24 Jul 2002 02:29:25 -0400

          From comp.compilers

Related articles
Exception Handling david.jobet@ng-market.com (David Jobet) (2002-07-21)
Re: Exception Handling vbdis@aol.com (VBDis) (2002-07-24)
Re: Exception Handling casse@netcourrier.com (Casse Hugues) (2002-07-24)
Re: Exception Handling jacob@jacob.remcomp.fr (jacob navia) (2002-07-24)
Re: Exception Handling david.jobet@ng-market.com (David Jobet) (2002-07-25)
Re: Exception Handling journeyman@compilerguru.com (journeyman) (2002-08-04)
Re: Exception Handling nmm1@cus.cam.ac.uk (Nick Maclaren) (2002-08-10)
Re: Exception Handling marcov@toad.stack.nl (Marco van de Voort) (2002-08-10)
Re: Exception Handling max1@mbank.com.ua (Maxim Reznik) (2002-08-10)
Re: Exception Handling fjh@cs.mu.OZ.AU (Fergus Henderson) (2002-08-14)
[5 later articles]
| List of all articles for this month |

From: "jacob navia" <jacob@jacob.remcomp.fr>
Newsgroups: comp.compilers
Date: 24 Jul 2002 02:29:25 -0400
Organization: Wanadoo, l'internet avec France Telecom
References: 02-07-075
Keywords: C, translator, errors
Posted-Date: 24 Jul 2002 02:29:25 EDT

> Problem is I don't know how to get this return address in order to produce
> the good case (here h_addr and f_addr).
>
> Is there any way to get them using assembly ?
>


Yes, it has been done many times.


Most procedures do:
        push ebp
        movl esp,ebp


So, reading the adress pointed to by ebp you get the old ebp, i.e. the frame
of the calling procedure. The machine return address is at 4(ebp).


        when you do


void f(void)
{
        int a,b,c;
        foo();
        a+=b;


within foo, the return address is the address of the first opcode of the
a+=b operation. The value at (ebp) points to the frame of the calling
procedure, where you find a,b,c if you know the offsets. Addresing from esp
only, you find the return address at (esp) immediately after the call, but
esp varies when a call frame is being built and the frame of the called
procedure is done, so it is more difficult to use.


All this supposes a standard setting with frame optimizations off. If you
are optimizing many of those constructs could be optimized away.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.