当前位置: 技术问答>linux和unix
关于stack 的一个弱弱的问题,望大虾指点
来源: 互联网 发布时间:2015-07-30
本文导语: void fun1(int a, int b) { char buf_fun1[4]; ...... } void fun2(int a, int b , int c) { char buf_fun2[100]; ... } 在调用fun1,fun2时它们的stack分布有一些差异. fun1: stack(低地址) top of buf_fun1 ...
void fun1(int a, int b)
{
char buf_fun1[4];
......
}
void fun2(int a, int b , int c)
{
char buf_fun2[100];
...
}
在调用fun1,fun2时它们的stack分布有一些差异.
fun1:
stack(低地址) top of buf_fun1
fsp
ret
a
b
stack(高地址) ..
fun2:
stack(低地址) top of buf_fun2
有其他在top of buf_fun2和fsp之间??why????
fsp
ret
a
b
c
stack(高地址) ..
望大虾指点
{
char buf_fun1[4];
......
}
void fun2(int a, int b , int c)
{
char buf_fun2[100];
...
}
在调用fun1,fun2时它们的stack分布有一些差异.
fun1:
stack(低地址) top of buf_fun1
fsp
ret
a
b
stack(高地址) ..
fun2:
stack(低地址) top of buf_fun2
有其他在top of buf_fun2和fsp之间??why????
fsp
ret
a
b
c
stack(高地址) ..
望大虾指点
|
1.跟源代码注释没有关系
2.如此简单的代码,函数调用,堆栈不会出现问题
08048430 :
8048430: 55 push %ebp
8048431: 89 e5 mov %esp,%ebp
8048433: 83 ec 78 sub $0x78,%esp
8048436: c9 leave
8048437: c3 ret
08048438 :
8048438: 55 push %ebp
8048439: 89 e5 mov %esp,%ebp
804843b: 83 ec 04 sub $0x4,%esp
804843e: c9 leave
804843f: c3 ret
08048440 :
8048440: 55 push %ebp
8048441: 89 e5 mov %esp,%ebp
8048443: 83 ec 08 sub $0x8,%esp
8048446: 83 ec 04 sub $0x4,%esp
8048449: 6a 03 push $0x3
804844b: 6a 02 push $0x2
804844d: 6a 01 push $0x1
804844f: e8 dc ff ff ff call 8048430
8048454: 83 c4 10 add $0x10,%esp
8048457: 83 ec 08 sub $0x8,%esp
804845a: 6a 02 push $0x2
804845c: 6a 01 push $0x1
804845e: e8 d5 ff ff ff call 8048438
8048463: 83 c4 10 add $0x10,%esp
8048466: c9 leave
8048467: c3 ret
3.exe很搞笑 :)
2.如此简单的代码,函数调用,堆栈不会出现问题
08048430 :
8048430: 55 push %ebp
8048431: 89 e5 mov %esp,%ebp
8048433: 83 ec 78 sub $0x78,%esp
8048436: c9 leave
8048437: c3 ret
08048438 :
8048438: 55 push %ebp
8048439: 89 e5 mov %esp,%ebp
804843b: 83 ec 04 sub $0x4,%esp
804843e: c9 leave
804843f: c3 ret
08048440 :
8048440: 55 push %ebp
8048441: 89 e5 mov %esp,%ebp
8048443: 83 ec 08 sub $0x8,%esp
8048446: 83 ec 04 sub $0x4,%esp
8048449: 6a 03 push $0x3
804844b: 6a 02 push $0x2
804844d: 6a 01 push $0x1
804844f: e8 dc ff ff ff call 8048430
8048454: 83 c4 10 add $0x10,%esp
8048457: 83 ec 08 sub $0x8,%esp
804845a: 6a 02 push $0x2
804845c: 6a 01 push $0x1
804845e: e8 d5 ff ff ff call 8048438
8048463: 83 c4 10 add $0x10,%esp
8048466: c9 leave
8048467: c3 ret
3.exe很搞笑 :)
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。