gongliheng1 发表于 2014-08-11 11:31

请问Linux 为什么要在进程的内核栈的栈底保留8个byte?

本帖最后由 gongliheng1 于 2014-08-11 11:31 编辑

以ARM linux为例,能看到:
#define THREAD_START_SP       (THREAD_SIZE - 8 )
这8个byte是干什么用的?

Tinnal 发表于 2014-08-13 22:39

回复 1# gongliheng1

抱歉,没有回答你这个问题,我看你在stackoverflow发贴了,也有人回答你了。
按8字节对齐是应该的,原因在ARM手册里和stackoverflow里都回得比较清楚了。这个我在看到你的贴时,已经知道。

但其实8K的边界已经满足8字节对齐的要求(8091 mod 8 = 0),从这点来说2,没有必要再-8。对于再保留8字节的问题,stackoverflow两个人都没有说清楚,都只是在猜想。


1.Peeking on stack

For the very top frame, we may want to take a peek at previous data. In order not to constantly check that the stack is in the 8K range an extra entry is reserved. Specifically, I think that signals need to peek at the stack.


2. Since stack is full-descending

THREAD_START_SP (THREAD_SIZE - 8)
would enforce this requirement probably by illegal access to next page (segmentation fault).


我没有stackoverflow账号,你是否可以追问一下,或者在邮件列表里发发邮件。被你这么一说,我也很好奇。


   
页: [1]
查看完整版本: 请问Linux 为什么要在进程的内核栈的栈底保留8个byte?