Re: Stack frame in GCC/G++

Michael Meissner <meissner@cygnus.com>
11 Oct 1999 02:37:19 -0400

          From comp.compilers

Related articles
Stack frame in GCC/G++ pradeep@cs.iastate.edu (pradeep bollineni) (1999-10-01)
Re: Stack frame in GCC/G++ meissner@cygnus.com (Michael Meissner) (1999-10-11)
| List of all articles for this month |

From: Michael Meissner <meissner@cygnus.com>
Newsgroups: comp.compilers
Date: 11 Oct 1999 02:37:19 -0400
Organization: Cygnus Solutions
References: 99-10-006
Keywords: C, GCC, code

pradeep bollineni <pradeep@cs.iastate.edu> writes:


> In code generated by gcc/g++ on linux running on intel pentium II, is
> any other data stored between a stack frames (for a function) base
> pointer and the return address from that function (which also stored
> on the stack). Put differently, is it correct to assume that return
> address from a function is stored right next to the base pointer for
> the functions stack frame?


And John writes in reply:
> [As I recall, with a sufficiently high optimization level, leaf routines
> someties don't store the base pointer. -John]


If the frame pointer is eliminated, then the frame pointer (base
pointer) is not stored next to the PC. There are two switches that
control this behavior:


-fomit-frame-pointer Try to eliminate all frame pointers
-momit-leaf-frame-pointer Only eliminate fp in leaf functions


Unlike many of the RISC targets, the frame pointer is not eliminated
by default on the x86, since the debugger can't deal with non-leaf
functions having no frame (the problem on the x86 is that it uses
pushes/pops in passing the arguments, so the stack pointer ebbs and
flows during the course of a function).
--
Michael Meissner, Cygnus Solutions
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886
email: meissner@cygnus.com phone: 978-486-9304 fax: 978-692-4482


Post a followup to this message

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