ELF二进制编译海湾合作委员会:从入口点发生主要是什么? [英] ELF-Binary compiled by gcc: What happens from entry point to main?
问题描述
我得到readelf -h入口点:
I get the entry point with readelf -h:
入口地址:0x8048400
Entry point address: 0x8048400
用GDB进行调试和Intel语法:
Debugging with gdb and Intel syntax:
(gdb) x/13i 0x8048400
0x8048400 <_start>: xor ebp,ebp
0x8048402 <_start+2>: pop esi
0x8048403 <_start+3>: mov ecx,esp
0x8048405 <_start+5>: and esp,0xfffffff0
0x8048408 <_start+8>: push eax
0x8048409 <_start+9>: push esp
0x804840a <_start+10>: push edx
0x804840b <_start+11>: push 0x8048590
0x8048410 <_start+16>: push 0x8048520
0x8048415 <_start+21>: push ecx
0x8048416 <_start+22>: push esi
0x8048417 <_start+23>: push 0x80484b4
0x804841c <_start+28>: call 0x80483e0 <__libc_start_main@plt>
0x80484b4,我的主要函数的地址,被压入堆栈。
0x80484b4, the address of my main function, is pushed on the stack.
(gdb) x/1i 0x80483e0
0x80483e0 <__libc_start_main@plt>: jmp DWORD PTR ds:0x8049800
这是怎么回事?当我跳到0x8049800我得到以下结果:
What is happening here? When I jump to 0x8049800 I get the following result:
(gdb) x/9i 0x8049800
0x8049800 <__libc_start_main@got.plt>: out 0x83,al
0x8049802 <__libc_start_main@got.plt+2>: add al,0x8
0x8049804 <sub@got.plt>: test BYTE PTR [ebx+0x804],0x0
0x804980b <data_start+3>: add BYTE PTR [eax],al
0x804980d: add BYTE PTR [eax],al
0x804980f: add BYTE PTR [eax],al
0x8049811 <dtor_idx.5525+1>: add BYTE PTR [eax],al
0x8049813 <dtor_idx.5525+3>: .byte 0x0
0x8049814: Cannot access memory at address 0x8049814
我不知道过程如何继续。你能帮助我吗?
I don't know how process continues. Can you help me?
推荐答案
我发现的话题一个不错的博客文章:的 http://bharathi.posterous.com/bash-prompt-to-main-call
I found a nice blog article about the topic: http://bharathi.posterous.com/bash-prompt-to-main-call
简短的回答:__libc_start_main()是libc函数,该函数调用主要功能(和做了很多其他的事情)。地址将在启动时(见BlackBears 链接)相连,这就是为什么从如下的步骤由静态调试程序入口到主要的功能是不可能的。
Short answer: __libc_start_main() is a libc function, which calls the main function (and does a lot of other things). The address will be linked at startup (see BlackBears link), that's why following the steps from the program entry to the main function by static debugging isn't possible.
但是你可以通过推计算出主函数的地址__libc_start_main调用之前。
But you can figure out the address of the main function through the push before __libc_start_main is called.
&0x8048417 LT; _start + 23>:推0x80484b4
0x8048417 <_start+23>: push 0x80484b4
@BlackBear:谢谢你的链接
@BlackBear: Thank you for the link!
这篇关于ELF二进制编译海湾合作委员会:从入口点发生主要是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!