我正在做一些X86演习;我的任务是通过《<代码>write(<>的图书馆拨打,直到我们达到《
│0xf7fdf421 <__kernel_vsyscall+1> push %edx
│0xf7fdf422 <__kernel_vsyscall+2> push %ebp
│0xf7fdf423 <__kernel_vsyscall+3> mov %esp,%ebp
│0xf7fdf425 <__kernel_vsyscall+5> sysenter
Is this what I should see? If so, why is it different from what some of my classmates saw?
Also are %edx and %ebp registers saved on the stack before executing the sysenter
instruction? (Would it not seem so according to the answer I got or am I wrong?)
这里,我从我的委任中的最初指示是:
法典:
.file "A3Program2.c"
.section .rodata
.LC0:
.string "hello
"
.LC1:
.string "xxxx
"
.text
.globl secondCall
.type secondCall, @function
secondCall:
pushl %ebp
movl %esp, %ebp
subl $40, %esp
movl $6, 8(%esp)
movl $.LC0, 4(%esp)
movl $1, (%esp)
call write
movl %eax, -12(%ebp)
movl $8, 8(%esp)
movl $.LC1, 4(%esp)
movl $1, (%esp)
call write
addl %eax, -12(%ebp)
movl 12(%ebp), %eax
movl 8(%ebp), %edx
leal (%edx,%eax), %eax
addl %eax, -12(%ebp)
movl -12(%ebp), %eax
leave
ret
.size secondCall, .-secondCall
.globl firstCall
.type firstCall, @function
firstCall:
pushl %ebp
movl %esp, %ebp
subl $40, %esp
movl $2, 4(%esp)
movl $4, (%esp)
call secondCall
movl %eax, -12(%ebp)
movl -12(%ebp), %eax
leave
ret
.size firstCall, .-firstCall
.globl main
.type main, @function
main:
pushl %ebp
movl %esp, %ebp
andl $-16, %esp
subl $16, %esp
call firstCall
movl %eax, 12(%esp)
movl $0, %eax
leave
ret
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5"
.section .note.GNU-stack,"",@progbits
www.un.org/Depts/DGACM/index_spanish.htm 下面的指令是:。
Find the line number of the second call to write, “call write”, in the secondCall function. 就此规定一个起点。 Which is 22 according to me.
就此规定一个起点。
break 22
Run the program inside the debugger.
run
The program will stop at the break point you set. Step into the code which does not have the debugging information.
si
You will see “[ No Source Available ]” in the source layout. So you need to view the disassembled instructions.
layout asm
Repeatedly step into (si and then return/enter will execute the si command repeatedly) until you see “sysenter” appear in the asm layout section of the screen. I am trying to copy the instructions (including their addresses) from the top of the asm layout section, down to and including the sysenter instruction.
Hint: You can change the focus of the keyboard to the command area by typing Ctrl-x o. This way the arrow keys can be used to bring back earlier commands (it just saves some typing).