This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

still using frame pointer when compiling with -fomit-frame-pointer


Hi.

For a little project of mine I use the -fomit-frame-pointer flag
to GCC, to let it know that it should not use %ebp (since it will
be clobbed in runtime generated code).  It works pretty good,
with the exception of the "main" function.  GCC generates the
following code; making my program SEGV on the "leave" insn (since
%ebp is not what it expects).

Is this what I can expect of GCC?  If so, is there any workaround
I could use?

$ gcc --version
gcc (GCC) 3.2.1 20030202 (Red Hat Linux 8.0 3.2.1-7)

All flags to GCC:

gcc -DHAVE_CONFIG_H -Wall -g  -fomit-frame-pointer -c x.c

This is the generated code:

00000000 <main>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   83 e4 f0                and    $0xfffffff0,%esp
   9:   b8 00 00 00 00          mov    $0x0,%eax
   e:   29 c4                   sub    %eax,%esp
  10:   e8 fc ff ff ff          call   11 <main+0x11>
                        11: R_386_PC32  _initialize_translator
  15:   83 ec 08                sub    $0x8,%esp
  18:   6a 00                   push   $0x0
  1a:   68 00 00 00 00          push   $0x0
                        1b: R_386_32    cpu
  1f:   e8 fc ff ff ff          call   20 <main+0x20>
                        20: R_386_PC32  main_loop
  24:   83 c4 10                add    $0x10,%esp
  27:   b8 00 00 00 00          mov    $0x0,%eax
  2c:   c9                      leave  
  2d:   c3                      ret    



-- 
Johan Rydberg, Free Software Developer, Sweden
http://rtmk.sf.net | http://www.nongnu.org/guss/

Playing The Supermen Lovers - Diamonds For Her


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]