我真的很想理解从高级代码到可执行文件的步骤..但是遇到了一些困难。
我写了一个空的int main() {}
C 文件并尝试通过以下方式破译反汇编objdump -d
。这是发生的事情:
- in
_start
,设置对齐方式,将参数压入堆栈,调用__libc_start_main
- in
__libc_start_main
,执行的第一行是jmp *0x8049658
然而,使用后objdump -R
查看搬迁记录,值在0x8049658
is __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
第一个块以“@plt”结尾,是程序链接表 (https://stackoverflow.com/a/5469334/994153 https://stackoverflow.com/a/5469334/994153). The jmp *0x8049658
是一个间接分支指令,所以它实际上是跳转到__libc_start_main
无论它在哪里actually最终在运行时加载到 RAM 中。
真实RAM地址__libc_start_main
可以在 DYNAMIC RELOCATION RECORDS 表中找到,该表是在程序加载时由动态加载器在 RAM 中创建的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)