Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

What is the role of stack in a microprocessor?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
569 views
Welcome To Ask or Share your Answers For Others

1 Answer

Stack is used largely during a function call but depending on the language and level of programming it may be used to temporarily store processor register data or other variables.

Further, the stack may also be used for short-term large-scale storage of data when using recursive functions that store partial data in the stack and call themselves again.

The generic use of stack is for,

  1. Return address
    • return value
    • parameters to called function
    • local variables in the called function
    • processor registers that will be reused in the called function

And, yes, stack is also used for exploits.
Its nature of carrying the return-address to where a called function returns back, coupled with the weakness of array-bounds checks in the C language, gives a very nice way to cause buffer overflows in the stack of a vulnerable (unsafely written) program.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...