本文作者:qiaoqingyi

会编程序是(会编程序是什么)

qiaoqingyi 01-29 132

  问题:谁调用了 main函数?

  在C语言的层面来看,main函数是一个程序的起始入口点,而实际上,ELF可执行文件的入口点并不是main而是_start。

  mdb也可以反汇编_start:

   _start::dis ;从_start 的地址开始反汇编

  _start: pushl $0

  _start+2: pushl $0

  _start+4: movl %esp,%ebp

  _start+6: pushl %edx

  _start+7: movl $0x80504b0,%eax

  _start+0xc: testl %eax,%eax

  _start+0xe: je +0xf _start+0x1d

  _start+0x10: pushl $0x80504b0

  _start+0x15: call -0x75

  _start+0x1a: addl $4,%esp

  _start+0x1d: movl $0x8060710,%eax

  _start+0x22: testl %eax,%eax

  _start+0x24: je +7 _start+0x2b

  _start+0x26: call -0x86

  _start+0x2b: pushl $0x80506cd

  _start+0x30: call -0x90

  _start+0x35: movl +8(%ebp),%eax

  _start+0x38: leal +0x10(%ebp,%eax,4),%edx

  _start+0x3c: movl %edx,0x8060804

  _start+0x42: andl $0xf0,%esp

  _start+0x45: subl $4,%esp

  _start+0x48: pushl %edx

  _start+0x49: leal +0xc(%ebp),%edx

会编程序是(会编程序是什么)

  _start+0x4c: pushl %edx

  _start+0x4d: pushl %eax

  _start+0x4e: call +0x152 _init

  _start+0x53: call -0xa3 __fpstart

  _start+0x58: call +0xfb ;在这里调用了main函数

  _start+0x5d: addl $0xc,%esp

  _start+0x60: pushl %eax

  _start+0x61: call -0xa1

  _start+0x66: pushl $0

  _start+0x68: movl $1,%eax

  _start+0x6d: lcall $7,$0

  _start+0x74: hlt

阅读
分享