当前位置:  技术问答>linux和unix

helloworld disassemble 問題

    来源: 互联网  发布时间:2016-05-06

    本文导语:  int main(int argc,char *argv[]) {     printf("hello world!n");     return 1; } gdb disassemble 後,能否解釋一下大概的動作在作什麼,跟直接寫汇編不太一樣 (gdb) disassemble main Dump of assembler code for function main: 0x08048374 :   ...

int main(int argc,char *argv[])
{
    printf("hello world!n");
    return 1;
}
gdb disassemble 後,能否解釋一下大概的動作在作什麼,跟直接寫汇編不太一樣

(gdb) disassemble main
Dump of assembler code for function main:
0x08048374 :    lea    0x4(%esp),%ecx
0x08048378 :    and    $0xfffffff0,%esp
0x0804837b :    pushl  -0x4(%ecx)
0x0804837e :   push   %ebp
0x0804837f :   mov    %esp,%ebp
0x08048381 :   push   %ecx
0x08048382 :   sub    $0x4,%esp
0x08048385 :   movl   $0x804845c,(%esp)
0x0804838c :   call   0x80482d4 
0x08048391 :   mov    $0x1,%eax
0x08048396 :   add    $0x4,%esp
0x08048399 :   pop    %ecx
0x0804839a :   pop    %ebp
0x0804839b :   lea    -0x4(%ecx),%esp
0x0804839e :   ret
End of assembler dump.

|

0x08048374 :    lea    0x4(%esp),%ecx            // 将 esp + 4 保存到 ecx,以便后面恢复原始堆栈
0x08048378 :    and    $0xfffffff0,%esp          // esp 向下取整到 16 字节对齐边界
0x0804837b :    pushl  -0x4(%ecx)                // 压入原 esp
0x0804837e :  push  %ebp                        // 压入 ebp
0x0804837f :  mov    %esp,%ebp                  // 将 esp 赋值给 ebp
0x08048381 :  push  %ecx                        // 压入 ecx
0x08048382 :  sub    $0x4,%esp                  // 保留 printf 的变参空间,但是在 printf 中不会使用到
0x08048385 :  movl  $0x804845c,(%esp)           // 将 "hello world" 字符串的起始地址(指针)压入堆栈
0x0804838c :  call  0x80482d4         // 调用函数 printf
0x08048391 :  mov    $0x1,%eax                  // 将返回值设置为 1
0x08048396 :  add    $0x4,%esp                  // 弹出"hello world"指针
0x08048399 :  pop    %ecx                       // 弹出 ecx
0x0804839a :  pop    %ebp                       // 弹出 ebp
0x0804839b :  lea    -0x4(%ecx),%esp            // 恢复到进入 main 函数时的原始堆栈形态
0x0804839e :  ret 

|


因为没有引用stdio。h,所以,链接了内部函数

    
 
 

您可能感兴趣的文章:

 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • 菜鸟问题:HelloWorld 也会出
  • HelloWorld的问题
  • helloworld编译成功,但是运行的时候出错。
  • 加载内核模块运行helloworld与应用程序helloworld执行过程的区别?
  • 第一个Java程序HelloWorld居然错了。
  • 自编译的helloworld程序不能同时在两个linux系统中执行????
  • 菜鸟级问题:HelloWorld程序运行出错???
  • java helloworld出错
  • 急救!!!简单的HELLOWORLD程序,编译痛不过
  • 我 的helloworld程序遇到下面的错误是怎么回事?
  • docker中文入门学习手册 iis7站长之家
  • 运行helloworld时出现错误,怎么回事?
  • HelloWorld问题?
  • Android的社交网络 HelloWorld goes mobile
  • gcc helloworld 出现错误......
  • 请教Linux下C程序HelloWorld运行问题(初级)
  • Linux 下 HelloWorld 问题
  • JAVA菜鸟提问了,HELLOWORLD通不过!!
  • Exception in thread "main" java.lang.NoClassDefFoundError:d:javahelloworld是怎么回事
  • ejb新手入门,生成helloworld.jar之后该做什么!


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3