How can I determine the return address on stack?

前端 未结 6 2278
旧巷少年郎
旧巷少年郎 2020-12-28 17:29

I know that if I am inside some function foo() which is called somewhere from bar() function, then this return address is pushed on stack.

6条回答
  •  梦谈多话
    2020-12-28 18:02

    When you declare local variables, they are also on the stack - x, for instance.

    If you then declare an int * xptr and initialize it to &x, it will point at x.

    Nothing (much) stops you from decrementing that pointer to peek a little before, or incrementing it to look later. Somewhere around there is your return address.

提交回复
热议问题