我真的想了解高级代码的步骤 - >可执行..但我遇到了一些困难。
我写了一个空的int main() {}
C文件,并尝试通过objdump -d
解密反汇编。这是正在发生的事情:
_start
中,设置对齐,在堆栈上推送参数,调用__libc_start_main
__libc_start_main
中,要执行的第一行是jmp *0x8049658
但是,使用objdump -R
签出重定位记录后,0x8049658
中的值为__libc_start_main
本身!
我在这里错过了一些东西......
编辑:这是一些来源;
080482c0 <__libc_start_main@plt>:
80482c0: ff 25 58 96 04 08 jmp *0x8049658
80482c6: 68 08 00 00 00 push $0x8
80482cb: e9 d0 ff ff ff jmp 80482a0 <_init+0x2c>
Disassembly of section .text:
080482d0 <_start>:
80482d0: 31 ed xor %ebp,%ebp
80482d2: 5e pop %esi
80482d3: 89 e1 mov %esp,%ecx
80482d5: 83 e4 f0 and $0xfffffff0,%esp
80482d8: 50 push %eax
80482d9: 54 push %esp
80482da: 52 push %edx
80482db: 68 50 84 04 08 push $0x8048450
80482e0: 68 e0 83 04 08 push $0x80483e0
80482e5: 51 push %ecx
80482e6: 56 push %esi
80482e7: 68 d0 83 04 08 push $0x80483d0
80482ec: e8 cf ff ff ff call 80482c0 <__libc_start_main@plt>
80482f1: f4 hlt
80482f2: 66 90 xchg %ax,%ax
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
08049644 R_386_GLOB_DAT __gmon_start__
08049654 R_386_JUMP_SLOT __gmon_start__
08049658 R_386_JUMP_SLOT __libc_start_main
答案 0 :(得分:9)
以“@plt”结尾的第一个块是过程链接表(https://stackoverflow.com/a/5469334/994153)。 jmp *0x8049658
是一个间接分支指令,因此它实际上跳转到__libc_start_main
,而实际最终会在运行时加载到RAM中。
__libc_start_main
的实际RAM地址位于DYNAMIC RELOCATION RECORDS表中,该表在加载程序时由动态加载程序在RAM中创建。