栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

试图了解gcc在main顶部复制返回地址的复杂堆栈对齐方式

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

试图了解gcc在main顶部复制返回地址的复杂堆栈对齐方式

我已经尝试了:

;# As you have already noticed, the compiler wants to align the stack;# pointer on a 16 byte boundary before it pushes anything. That's;# because certain instructions' memory access needs to be aligned;# that way.;# So in order to first save the original offset of esp (+4), it;# executes the first instruction:lea    ecx,[esp+0x4];# Now alignment can happen. Without the previous insn the next one;# would have made the original esp unrecoverable:and    esp,0xfffffff0;# Next it pushes the return addresss and creates a stack frame. I;# assume it now wants to make the stack look like a normal;# subroutine call:push   DWORD PTR [ecx-0x4]push   ebpmov    ebp,esp;# Remember that ecx is still the only value that can restore the;# original esp. Since ecx may be garbled by any subroutine calls,;# it has to save it somewhere:push   ecx


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/408764.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号