21,453
社区成员
发帖
与我相关
我的任务
分享
(gdb) info registers
eax 0x3ff 1023
ecx 0x8 8
edx 0x0 0
ebx 0x3ff 1023
esp 0xbfae1a30 0xbfae1a30
ebp 0x0 0x0
esi 0x0 0
edi 0x0 0
eip 0x8048060 0x8048060 <_start+12>
eflags 0x210292 2163346
cs 0x73 115
ss 0x7b 123
ds 0x7b 123
es 0x7b 123
fs 0x0 0
gs 0x0 0
(gdb)
.text
.global _start
_start:
nop
movb $0x08,%bl
movb %bl,%cl
movw $0x03ff,%ax
movw %ax,%bx
movw %bx,%ds:(0x0020)
movl $0,%ebx
movl $1,%eax
int $0x80
[mzlogin@localhost Desktop]$ make
as -g -o 1.o 1.s
ld -o 1 1.o
[mzlogin@localhost Desktop]$ gdb 1
GNU gdb Everest Linux (6.4-1)
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1".
(gdb) l
1 .text
2 .global _start
3
4 _start:
5 nop
6 movb $0x08,%bl
7 movb %bl,%cl
8 movw $0x03ff,%ax
9 movw %ax,%bx
10 movw %bx,%ds:(0x0020)
(gdb) b * _start+1
Breakpoint 1 at 0x8048055: file 1.s, line 6.
(gdb) r
Starting program: /home/mzlogin/Desktop/1
Breakpoint 1, _start () at 1.s:6
6 movb $0x08,%bl
Current language: auto; currently asm
(gdb) n
_start () at 1.s:7
7 movb %bl,%cl
(gdb) n
_start () at 1.s:8
8 movw $0x03ff,%ax
(gdb) n
_start () at 1.s:9
9 movw %ax,%bx
(gdb) n
_start () at 1.s:10
10 movw %bx,%ds:(0x0020)
(gdb) info registers
eax 0x3ff 1023
ecx 0x8 8
edx 0x0 0
ebx 0x3ff 1023
esp 0xbfae1a30 0xbfae1a30
ebp 0x0 0x0
esi 0x0 0
edi 0x0 0
eip 0x8048060 0x8048060 <_start+12>
eflags 0x200292 2097810
cs 0x73 115
ss 0x7b 123
ds 0x7b 123
es 0x7b 123
fs 0x0 0
gs 0x0 0
(gdb) n
Program received signal SIGSEGV, Segmentation fault.
_start () at 1.s:10
10 movw %bx,%ds:(0x0020)
(gdb)