asker160 发表于 2016-09-21 21:40

把esp的内容存起来再读取,会导致SIGSEGV,为何?

我在ubuntu1604,64位版本下面,我有一个小的试验程序:

$ cat g.s
.code32
.globl _start
_start:
push $3
push $2
movl 8(%esp),%ebx #我打算修改这里

movl $1,%eax
int $0x80

编译运行没有问题
但是如果我把movl 8(%esp),%ebx改成先保存esp到ebp,再使用ebp,就失败了

$ cat f.s
.code32
.globl _start
_start:
push $3
push $2
movl %esp,%ebp
movl 8(%ebp),%ebx

movl $1,%eax
int $0x80

编译运行这个程序就core dump了,core在movl 8(%ebp),%ebx这一行。
这是为什么呢?

页: [1]
查看完整版本: 把esp的内容存起来再读取,会导致SIGSEGV,为何?