[lkml]   [2000]   [Sep]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: kernel compiled with frame pointer
On Sat, 23 Sep 2000 15:02:26 +0530 (IST), 
Sushil <> wrote:
> While writing kernel code what is the correct way to find out if the
>kernel is being compiled with frame pointer?

Sad to say, you cannot. This is an extract from the kdb patch

* An activation record runs from the return address for a function
* through to the return address for the next function or sp, whichever
* comes first. For each activation record we extract :-
* start Address of the activation record.
* end Address of the last byte+1 in the activation record.
* ret Return address to caller.
* oldfp Frame pointer to previous frame, 0 if this function was
* not compiled with frame pointers.
* fp Frame pointer for the current frame, 0 if this function
* was not compiled with frame pointers or fp has not been
* set yet.
* arg0 Address of the first argument (in the previous activation
* record).
* locals Bytes allocated to locals and automatics.
* regs Bytes allocated to saved registers.
* args Bytes allocated to arguments (in the previous activation
* record).
* setup Bytes allocated to setup data on stack (return address,
* frame pointer).
* Although the kernel might be compiled with frame pointers, we still
* have to assume the worst and validate the frame. Some calls from
* asm code to C code might not use frame pointers. Third party binary
* only modules might be compiled without frame pointers, even when the
* rest of the kernel has frame pointers. Some routines are always
* compiled with frame pointers, even if the overall kernel is not. A
* routine compiled with frame pointers can be called from a routine
* without frame pointers, the previous "frame pointer" is saved on
* stack but it contains garbage.
* We check the object code to see if it saved a frame pointer and we
* validate that pointer. Basically frame pointers are hints.

>Is the following code correct?
> code assuming frame pointer
> code assuming no frame pointer

Not really, see above. You code might be compiled with frame pointers
but you can never tell how your caller was compiled so you cannot trust
the "frame pointer" that you were given.

>The top level Makefile that comes with the standard kernels (the ones
>which can be downloaded from etc.) adds -fomit-frame-pointer to
>CFLAGS by default and it does not have something like
>CFLAGS += -fomit-frame-pointer
>Is CONFIG_FRAME_POINTER a part of some external patch?
>If yes, then is there a way to find the above in the standard

Some architectures require you to have a frame pointer, on those
-fomit-frame-pointer is a null flag. On other architectures it is
optional and they tend to have extra flags in arch/xxx/Makefile.

>What about CONFIG_KDB_FRAMEPTR? Is it correct to use this in a standard
>kernel to find whether the kernel is being compiled with frame pointer?

I don't know which kernel you are looking at. CONFIG_KDB_FRAMEPTR is
part of an old kdb patch, not part of the standard kernel. It has been
removed from current kdb patches, kdb patches after May 9 2000 use

Keith Owens, kdb maintainer.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:38    [W:0.059 / U:1.212 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site