到底在哪X86-64上的红色区域? [英] Where exactly is the red zone on x86-64?

查看:327
本文介绍了到底在哪X86-64上的红色区域?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

维基百科


  

在计算中,红色区域是在功能的之外是不通过该函数pserved $ P $返回地址堆栈帧的固定大小的区域。在被调用函数可以使用红色区域,用于存储局部变量,而无需修改堆栈指针的额外开销。存储器中的该区域不被中断/异常/信号处理程序进行修改。通过系统V使用的X86-64 ABI责成返回地址后,128字节的红色区域,这直接开始的,包括函数的参数即可。该OpenRISC工具链假定一个128字节的红色区域。


System V的ABI X86-64 :


  

128字节的区域之外的位置指向%RSP 被认为
  被保留,不受信号或中断处理程序进行修改。因此,函数可以使用该区域未在函数调用所需的临时数据。尤其是,叶函数可以使用此区域为他们的整个堆栈帧,而不是在序幕和尾声调整堆栈指针。这个区域被称为红色区域。



  • 由于这两个报价,是的红色区域上述堆叠的返回地址或下面堆叠的返回地址?


  • 由于此的红色区域的是相对于 RSP ,它与每个按<向下移动/ code>键,它与每个弹出



解决方案

  

由于这两个报价,是红色区域上方堆积的返回地址或下方堆叠的返回地址?


红色区域是略低于 RSP ,即 RSP 128字节 - 128 RSP - 1


  

由于这个红色区域是相对于可吸入悬浮粒子,它向下与每个推移动,它与每个弹出向上移动?


From Wikipedia:

In computing, a red zone is a fixed-size area in a function's stack frame beyond the return address which is not preserved by that function. The callee function may use the red zone for storing local variables without the extra overhead of modifying the stack pointer. This region of memory is not to be modified by interrupt/exception/signal handlers. The x86-64 ABI used by System V mandates a 128-byte red zone, which begins directly after the return address and includes the function's arguments. The OpenRISC toolchain assumes a 128-byte red zone.

From the System V x86-64 ABI:

The 128-byte area beyond the location pointed to by %rsp is considered to be reserved and shall not be modified by signal or interrupt handlers. Therefore, functions may use this area for temporary data that is not needed across function calls. In particular, leaf functions may use this area for their entire stack frame, rather than adjusting the stack pointer in the prologue and epilogue. This area is known as the red zone.

  • Given these two quotes, is the red zone above the stacked return address or below the stacked return address?

  • Since this red zone is relative to RSP, does it move downward with each push and does it move upward with each pop?

解决方案

Given these two quotes, is the red zone above the stacked return address or below the stacked return address?

The red zone is the 128 bytes just below rsp, i.e. rsp - 128 to rsp - 1.

Since this red zone is relative to RSP, does it move downward with each push and does it move upward with each pop?

Yes.

这篇关于到底在哪X86-64上的红色区域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆