首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么我的装配程序会出现分段故障?

为什么我的装配程序会出现分段故障?
EN

Stack Overflow用户
提问于 2015-06-28 15:56:45
回答 1查看 220关注 0票数 0

我必须调试以下代码:

代码语言:javascript
复制
    global _start
_start:
pop esp
js 0x36
xor [eax+edi*2+0x43],ebx
xor [eax+edi*2+0x35],bl
xor [eax+edi*2+0x36],bl
cmp [eax+edi*2+0x37],bl
ss pop esp
js 0x49
aaa
pop esp
js 0x52
xor al,0x5c
js 0x56
xor al,0x5c
js 0x59
cmp [eax+edi*2+0x37],bl
xor ebx,[eax+edi*2+0x32]
xor al,0x5c
js 0x61
xor eax,0x3532785c
pop esp
js 0x6d
cmp [eax+edi*2+0x32],bl
xor [eax+edi*2+0x32],bl
xor ebx,[eax+edi*2+0x32]
xor eax,0x3332785c
pop esp
js 0x81
cmp [eax+edi*2+0x37],bl
cmp [eax+edi*2+0x32],bl
xor al,0x5c
js 0x8e
xor eax,0x3532785c
pop esp
js 0x95
cmp [eax+edi*2+0x37],bl
cmp [eax+edi*2+0x32],bl
xor [eax+edi*2+0x37],bl
xor bl,[eax+edi*2+0x32]
xor [eax+edi*2+0x36],bl
cmp [eax+edi*2+0x37],bl
xor [eax+edi*2+0x37],bl
xor [eax+edi*2+0x37],bl
xor eax,0x3637785c
pop esp
js 0xbd
cmp [eax+edi*2+0x32],bl
aaa
pop esp
js 0xc6
xor al,0x5c
js 0xca
cmp [eax+edi*2+0x32],bl
aaa
pop esp
js 0xd1
cmp [eax+edi*2+0x37],bl
cmp [eax+edi*2+0x32],ebx
aaa
pop esp
js 0xd9
xor al,0x5c
js 0xe2
xor bl,[eax+edi*2+0x36]
cmp [eax+edi*2+0x37],bl
xor bl,[eax+edi*2+0x37]
cmp [eax+edi*2+0x37],bl
cmp [eax+edi*2+0x37],ebx
cmp [eax+edi*2+0x36],bl
cmp [eax+edi*2+0x37],bl
ss pop esp
js 0xfd
aaa
pop esp
js 0x106
xor [eax+edi*2+0x32],bl
xor eax,0x3836785c
pop esp
js 0x112
cmp [eax+edi*2+0x37],bl
xor ebx,[eax+edi*2+0x32]
xor ebx,[eax+edi*2+0x32]
aaa
pop esp
js 0x121
cmp [eax+edi*2+0x32],bl
xor [eax+edi*2+0x37],bl
cmp [eax+edi*2+0x32],ebx
xor bl,[eax+edi*2+0x37]
xor eax,0x3836785c
pop esp
js 0x13a
xor [eax+edi*2+0x37],bl
xor [eax+edi*2+0x32],ebx
xor al,0x5c
js 0x141
xor ebx,[eax+edi*2+0x36]
cmp [eax+edi*2+0x37],bl
xor [eax+edi*2+0x37],ebx
xor ebx,[eax+edi*2+0x37]
cmp [eax+edi*2+0x37],ebx
xor [eax+edi*2+0x36],bl
cmp [eax+edi*2+0x32],bl
xor eax,0x3937785c
pop esp
js 0x16a
xor bl,[eax+edi*2+0x37]
xor bl,[eax+edi*2+0x36]
cmp [eax+edi*2+0x32],bl
aaa
pop esp
js 0x17a
cmp [eax+edi*2+0x32],bl
aaa
pop esp
js 0x182
xor eax,0x3836785c
pop esp
js 0x18a
cmp [eax+edi*2+0x37],bl
xor [eax+edi*2+0x37],bl
xor ebx,[eax+edi*2+0x37]
xor eax,0x3836785c
pop esp
js 0x19e
xor bl,[eax+edi*2+0x37]
cmp [eax+edi*2+0x32],bl
xor ebx,[eax+edi*2+0x37]
xor eax,0x3836785c
pop esp
js 0x1ad
xor eax,0x3032785c
pop esp
js 0x1ba
xor [eax+edi*2+0x32],bl
xor al,0x5c
js 0x1c1
cmp [eax+edi*2+0x37],bl
xor bl,[eax+edi*2+0x32]
xor eax,0x3637785c
pop esp
js 0x1d2
xor ebx,[eax+edi*2+0x36]
cmp [eax+edi*2+0x37],bl
xor bl,[eax+edi*2+0x32]
xor [eax+edi*2+0x37],bl
xor ebx,[eax+edi*2+0x37]
xor bl,[eax+edi*2+0x36]
cmp [eax+edi*2+0x37],bl
xor [eax+edi*2+0x32],ebx
xor [eax+edi*2+0x37],bl
xor [eax+edi*2+0x32],ebx
xor bl,[eax+edi*2+0x36]
cmp [eax+edi*2+0x32],bl
xor ebx,[eax+edi*2+0x37]
xor eax,0x3037785c
pop esp
js 0x20e
xor bl,[eax+edi*2+0x36]
cmp [eax+edi*2+0x32],bl
xor bl,[eax+edi*2+0x37]
xor al,0x5c
js 0x219
xor eax,0x3837785c
pop esp
js 0x225
cmp [eax+edi*2+0x37],bl
xor [eax+edi*2+0x37],ebx
aaa
pop esp
js 0x232
xor eax,0x3137785c
pop esp
js 0x239
cmp [eax+edi*2+0x32],bl
aaa
pop esp
js 0x242
xor bl,[eax+edi*2+0x37]
aaa
pop esp
js 0x245
xor bl,[eax+edi*2+0x36]
cmp [eax+edi*2+0x37],bl
xor [eax+edi*2+0x37],bl
xor [eax+edi*2+0x32],bl
aaa
pop esp
js 0x259
xor eax,0x3836785c
pop esp
js 0x266
aaa
pop esp
js 0x26a
xor ebx,[eax+edi*2+0x37]
cmp [eax+edi*2+0x32],bl
xor al,0x5c
js 0x275
cmp [eax+edi*2+0x37],bl
xor bl,[eax+edi*2+0x37]
cmp [eax+edi*2+0x37],bl
aaa
pop esp
js 0x286
xor al,0x5c
js 0x289
cmp [eax+edi*2+0x32],bl
aaa
pop esp
js 0x292
aaa
pop esp
js 0x291
aaa
pop esp
js 0x295
xor bl,[eax+edi*2+0x36]
cmp [eax+edi*2+0x32],bl
xor bl,[eax+edi*2+0x37]
xor al,0x5c
js 0x2a5
xor bl,[eax+edi*2+0x37]
xor eax,0x3836785c
pop esp
js 0x2b6
xor ebx,[eax+edi*2+0x37]
aaa
pop esp
js 0x2be
xor [eax+edi*2+0x37],bl
xor [eax+edi*2+0x35],bl
xor al,0x5c
js 0x2c8
inc ebp
pop esp
js 0x2cf
inc edx
pop esp
js 0x2e1
inc ebp
pop esp
js 0x2d7
inc edx
pop esp
js 0x2e7
aaa
pop esp
js 0x2ed
inc ebx
pop esp
js 0x2ed
cmp [eax+edi*2+0x38],ebx
xor [eax+edi*2+0x30],bl
xor [eax+edi*2+0x30],bl
xor [eax+edi*2+0x30],bl
xor [eax+edi*2+0x42],bl
inc edx
pop esp
js 0x2f7
xor [eax+edi*2+0x30],ebx
xor [eax+edi*2+0x30],bl
xor [eax+edi*2+0x30],bl
xor [eax+edi*2+0x33],bl
xor [eax+edi*2+0x43],ebx
xor [eax+edi*2+0x35],bl
xor [eax+edi*2+0x41],bl
inc ebx
pop esp
js 0x316
xor ebx,[eax+edi*2+0x43]
xor ebx,[eax+edi*2+0x41]
inc ecx
pop esp
js 0x334
xor bl,[eax+edi*2+0x46]
inc ecx
pop esp
js 0x32c
xor al,0x5c
js 0x330
inc ebp
pop esp
js 0x342
inc ebx
db 0x0a

在编译和运行该代码之后,我获得了一个分段错误,似乎在第5行之后出现了问题。我的linux知识是非常基础的,对于到底出了什么问题以及如何修复它,有什么提示或想法吗?

这段代码是调试练习的一部分,我这样做只是为了自动学习,这不是任何家庭作业或什么的一部分。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-06-28 16:57:42

我已经编译了您的示例,然后使用hexdump查看了它

(为了在32位模式下编译,我必须将BITS 32添加到其中,因为我使用的是Linux-64):

代码语言:javascript
复制
$ vi test.asm
$ nasm test.asm
$ hexdump -C test

00000000  5c 0f 88 2f 00 00 00 31  5c 78 43 30 5c 78 35 30  |\../...1\xC0\x50|
00000010  5c 78 36 38 5c 78 37 36  5c 0f 88 2a 00 00 00 37  |\x68\x76\..*...7|
00000020  5c 0f 88 2b 00 00 00 34  5c 0f 88 27 00 00 00 34  |\..+...4\..'...4|
00000030  5c 0f 88 22 00 00 00 38  5c 78 37 33 5c 78 32 34  |\.."...8\x73\x24|
00000040  5c 0f 88 1a 00 00 00 35  5c 78 32 35 5c 0f 88 1a  |\......5\x25\...|
00000050  00 00 00 38 5c 78 32 30  5c 78 32 33 5c 78 32 35  |...8\x20\x23\x25|
00000060  5c 78 32 33 5c 0f 88 16  00 00 00 38 5c 78 37 38  |\x23\......8\x78|
00000070  5c 78 32 34 5c 0f 88 13  00 00 00 35 5c 78 32 35  |\x24\......5\x25|
00000080  5c 0f 88 0e 00 00 00 38  5c 78 37 38 5c 78 32 30  |\......8\x78\x20|
........

你看到模式了吗?在右列(ASCII模式),您可以看到大量的文字\xNN,即不是字节NN,而是字符'\' 'x'和两个数字!

我的猜测是,您正在调试一些二进制代码的转储,但该代码尚未正确转储。因此,您正在查看的程序集是无稽之谈。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31101780

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档