Reputation: 5181
Is there any way to access the Stack Frame Pointer from Function Name/Address in a C Program?
I have tried to analyze the contents at memory addresses starting from the Function's Address in GDB, but could not get any meaningful information.
Can anybody please provide me some hint on this?
Thanks.
Upvotes: 0
Views: 1019
Reputation: 1281
Declare a variable at the top of the function and take an address of it ?
void foo()
{
int dbg;void* sfp = &dbg;
}
Upvotes: 1
Reputation: 213385
Is there any way to access the Stack Frame Pointer from Function Name/Address in a C Program?
Your question makes no sense: the name and address of a function in a C program is fixed at link time and (generally) doesn't change. The stack pointer on the other hand is a runtime property, and may change every time the function is called.
Since you mention GDB, yes, you can find out stack pointer when you are stopped inside the function, with e.g. info frame
GDB command.
Upvotes: 3