Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i configure a ARM processor for Ascending Stack growth direction?

Tags:

stack

arm

There has been one question here which talked about stack growth direction. To which Michael Burr had replied saying in ARM processors stack growth direction can be configured - i.e. either descending (normal behaviour) stack grows towards zero address (lower address) in memory or ascending, i.e. stack grows towards higher address in memory.

What is the direction of stack growth in most modern systems?

My question is: in ARM processors, how can I make the stack grow in ascending direction?

How do I configure the stack as ascending as by default it is descending? Any register bit set/reset, etc.

like image 868
goldenmean Avatar asked May 25 '09 11:05

goldenmean


1 Answers

Well, the ARM processors don't maintain a stack directly-- but they do have instructions that are designed with that in mind: LDM and STM. So if you use STMDB at the start of a function and LDMIA at the end, you effectively have a full+descending stack: the assemblers I remember using allowed you to write "STMFD" and "LDMFD" as aliases. (A "full" stack is one where the stack pointer points to the latest word on the stack, as opposed to the next location to use)

So it's not something you can simply reconfigure at runtime: although if you were writing your own operating system with its own call convention, you could choose to use an ascending stack. Similarly, you could also choose not to use R13 as the stack pointer- that's just part of the calling convention too. This choice effectively gets embedded into the implementation of every function that uses the stack.

like image 146
araqnid Avatar answered Oct 14 '22 22:10

araqnid