This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to get Call Stack from stack data.

Note: This was originally posted on 23rd January 2009 at http://forums.arm.com

Hi everyone.

   Here is a question that puzzled me a long time. if I get stack data(HEX data),  anyone konw that how to get call stack from it.

   How to know that which is R14.
Parents
  • Note: This was originally posted on 28th January 2009 at http://forums.arm.com

    Interesting question.

    Basically, the stack works because you read values off it in the opposite order to that which they were stored. r14's entry in the stack will not be obviously labelled as such, for example.

    Of course, this only works because C functions will be ABI compliant and thus don't mess up the stack pointer. If you write a function in assembly which doesn't correctly handle the stack pointer, everything will fall apart because what should be stored in r14 will end up somewhere else.

    Also, note that there may be many copies of r14 in the stack as it will be pushed every time a function needs to modify it. As r14 is the link register, that will occur for pretty much every function call.

    The only way to determine where r14 is located in the stack is to study your code and work out the address at which it will eventually be stored. Of course, you can use a debugger to do that for you by setting breakpoints and that kind of thing.

    Does that answer your question?
Reply
  • Note: This was originally posted on 28th January 2009 at http://forums.arm.com

    Interesting question.

    Basically, the stack works because you read values off it in the opposite order to that which they were stored. r14's entry in the stack will not be obviously labelled as such, for example.

    Of course, this only works because C functions will be ABI compliant and thus don't mess up the stack pointer. If you write a function in assembly which doesn't correctly handle the stack pointer, everything will fall apart because what should be stored in r14 will end up somewhere else.

    Also, note that there may be many copies of r14 in the stack as it will be pushed every time a function needs to modify it. As r14 is the link register, that will occur for pretty much every function call.

    The only way to determine where r14 is located in the stack is to study your code and work out the address at which it will eventually be stored. Of course, you can use a debugger to do that for you by setting breakpoints and that kind of thing.

    Does that answer your question?
Children
No data