Sandeep Singh
Sandeep Singh

Reputation: 5181

Can we access Stack Frame Pointer from Function Name

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

Answers (2)

AlexK
AlexK

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

Employed Russian
Employed Russian

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

Related Questions