编译一个最简单的c程序: //test.c int main() { int a=3,b=5; int c; c = a+b; printf("c is %d\n",c); } gcc -S -O2 test.c test.s: main: pushl %ebp movl %esp, %ebp subl $8, %esp andl $-16, %esp subl $16, %esp movl $8, 4(%esp) movl $.LC0, (%esp) call printf leave ret 我对其...
by maddrone - Linux文档专区 - 2008-01-17 11:23:30 阅读(1161) 回复(0)
写个程序调试
(gdb) disassemble main
0x0000000000400520
处理异常的时候,在标号为error_code的代码中,有这样一段代码:[code] // 在arch/x86/kernel/entry_32.S movl PT_GS(%esp), %edi # get the function address movl PT_ORIG_EAX(%esp), %edx # get the error code movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart [/code]我查了下PT_GS和PT_ORIG_EAX的值,发现定义在arch/ia64/ia32/sys_ia32.c中,如下[code] #define PT_GS 10 #define PT_ORIG_EAX 11 [/...
本帖最后由 C_H_L 于 2013-05-15 12:24 编辑 最近学习AT&T汇编,看到下面一段: function_label: pushl %ebp movl %esp, %ebp < normal function code goes here> movl %ebp, %esp popl %ebp ret 这段代码,目的是把esp放到ebp中 (1) 为什么红色部分还要把ebp压栈、出栈? (2) 没有pushl ...
本帖最后由 dugubai 于 2010-07-31 21:17 编辑 请问在内核的kgdb调试过程中,i r esp ebp命令显示的是不是堆栈指针的真实值? 为什么其值与通过如下汇编语句传出来的值不同?二者有何区别跟联系?二者跟p $sp, p $fp显示的堆栈值又有什么关系?[code]__asm__ __volatile__ ("movl %%esp, %0\n\t" "movl %%ebp, %1\n\t" : "=m" (espt), "=m" (ebpt) : : "memory");[/code]...