Re: Exception Handling

"jacob navia" <>
24 Jul 2002 02:29:25 -0400

          From comp.compilers

Related articles
Exception Handling (David Jobet) (2002-07-21)
Re: Exception Handling (VBDis) (2002-07-24)
Re: Exception Handling (Casse Hugues) (2002-07-24)
Re: Exception Handling (jacob navia) (2002-07-24)
Re: Exception Handling (David Jobet) (2002-07-25)
Re: Exception Handling (journeyman) (2002-08-04)
Re: Exception Handling (Nick Maclaren) (2002-08-10)
Re: Exception Handling (Marco van de Voort) (2002-08-10)
Re: Exception Handling (Maxim Reznik) (2002-08-10)
Re: Exception Handling (Fergus Henderson) (2002-08-14)
[5 later articles]
| List of all articles for this month |

From: "jacob navia" <>
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;

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.