arm架构下linux进程栈大小,关于ARMv8架构下函数栈

Hi All,

Q群里问问题不过瘾,还是来这边了

是一个有关v8架构下函数栈的问题,先帖代码:

/*

* AArch64 PCS assigns the frame pointer to x29.

*

* A simple function prologue looks like this:

* subsp, sp, #0x10

* stpx29, x30, [sp]

*movx29, sp

*

* A simple function epilogue looks like this:

*movsp, x29

*ldpx29, x30, [sp]

*addsp, sp, #0x10

*/

int notrace unwind_frame(struct stackframe *frame)

{

unsigned long high, low;

unsigned long fp = frame->fp;

low = frame->sp;

high = ALIGN(low, THREAD_SIZE);

if (fp < low || fp > high || fp & 0xf)

return -EINVAL;

frame->sp = fp + 0x10;

frame->fp = *(unsigned long *)(fp);

/*

* -4 here because we care about the PC at time of bl,

* not where the return will go.

*/

frame->pc = *(unsigned long *)(fp + 8) - 4;

return 0;

}

Q: 注释部分:

* A simple function prologue looks like this:

* subsp, sp, #0x10

* stpx29, x30, [sp]

*movx29, sp

大概做了以下几件事:

1. sp指针自减0x10

2. 将0x29(即FP)入栈,将0x30(即LR)入栈,地址为SP

3. 将FP寄存器的值赋给SP

那么是不是意味着,对于单个函数,函数栈的大小只能是0x10?如果函数中临时变量较多超出0x10怎么办?

之前我在x86架构下,确定一个函数的栈范围需要ESP和EBP两个指针,似乎ARM下是用FP和SP,并且FP的相邻地址就保存了LR

按照以上的说法,如果出现了系统崩溃的bug,似乎只需要知道FP指针,就可以推导函数调用的整个流程(因为相当于同时知道了LR)

最近编辑记录 showstopper (2016-05-31 22:21:01)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值