How are stack based structures passed to subroutines in ARM assembly?
For example:
typedef struct SomeStruct {
uint32_t one;
uint32_t two;
uint32_t three;
uint32_t four;
} SomeStruct;
void SomeFunction(uint32_t someValue, SomeStruct someStruct, uint32_t otherValue);
In this case, how would the structure be passed? My guess is:
r0–someValuer1–someStruct.oner2–someStruct.twor3–someStruct.three*sp–someStruct.four*sp,#4–otherValue
Is that correct or does something else happen? Or does it just pass the structure’s sp based address?
There’s a “procedure call standard” for an ARM ABI here: http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
There’s more than one ABI for ARM, and more again for 64 bit ARM, but just looking at this one, the relevant section is “5.5 Parameter Passing”. At a glance, I think C.5 says you’re right, this struct will be split between r1-r3 and the stack.
B.1, which can replace an argument of composite type with a pointer to a copy in memory, never applies in C, since both caller and callee must have
SomeStructas a complete type in order to pass by value.