0

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.

0

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, I know info frame command. Actually, I was trying to explore some way to access the FP using some pointer manipulation.
In order to access FP you need to start somewhere, and your question is entirely unclear on where you want to start from. It sounds like you want to start with the function address, but as I hopefully explained function address is completely unrelated to FP, so you can't get there from here. If you are starting somewhere else, please clarify your question so we can give you a better answer.
Thanks, I will get back on this after some more analysis.
1

Declare a variable at the top of the function and take an address of it ?

void foo()
{
int dbg;void* sfp = &dbg;

}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.