基于堆栈的结构如何传递给ARM程序集中的子程序?
例如:
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);
Run Code Online (Sandbox Code Playgroud)
在这种情况下,结构将如何通过?我的猜测是:
r0
- someValue
r1
- someStruct.one
r2
- someStruct.two
r3
- someStruct.three
*sp
- someStruct.four
*sp,#4
- otherValue
这是正确的还是会发生其他事情? 或者它只是通过结构的 sp
地址?
这里有一个ARM ABI的"过程调用标准":http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042d/IHI0042D_aapcs.pdf
ARM有多个ABI,64位ARM也是如此,但只看这一个,相关部分是"5.5参数传递".乍一看,我认为C.5说你是对的,这个结构将在r1-r3和堆栈之间分开.
B.1,它可以用指向内存中副本的指针替换复合类型的参数,从不在C中应用,因为调用者和被调用者必须具有SomeStruct
完整类型才能传递值.