Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

x86_64 : is stack frame pointer almost useless?

Tags:

People also ask

Is the frame pointer necessary?

You only absolutely need a frame pointer when dynamically allocating variable amounts of space on the stack. Functions that use variable length arrays and/or alloca in C are examples of functions that need a frame pointer.

Is frame pointer same as stack pointer?

The stack pointer always points to the top (or bottom, if you prefer) of the stack. The frame pointer always points to the frame. Stack operations (e.g., push, pop, call) do not modify the frame (in a properly operating system) or the frame pointer (ever).

What is stack frame pointer?

The stack pointer (the esp register on intel x86 architectures or rsp on 64-bit architectures) may change during the execution of a function as values are pushed or popped off the stack (such as pushing parameters in preparation to calling another function). The frame pointer doesn't change throughout the function.

When would you use a stack frame?

A stack frame is a memory management technique used in some programming languages for generating and eliminating temporary variables. In other words, it can be considered the collection of all information on the stack pertaining to a subprogram call. Stack frames are only existent during the runtime process.



  • Linux x86_64.
  • gcc 5.x

I was studying the output of two codes, with -fomit-frame-pointer and without (gcc at "-O3" enables that option by default).

pushq    %rbp movq     %rsp, %rbp ... popq     %rbp 

My question is :

If I globally disable that option, even for, at the extreme, compiling an operating system, is there a catch ?

I know that interrupts use that information, so is that option good only for user space ?