为了研究目标文件在linux中是如何加载和运行的,我制作了最简单的c代码,文件名为simple.c。
int main(){}
接下来,我创建目标文件并将目标文件另存为文本文件。
$gcc ./simple.c
$objdump -xD ./a.out > simple.text
从许多互联网文章中,我可以发现 gcc 动态加载启动函数,如 _start、_init、__libc_start_main@plt 等。所以我开始阅读我的汇编代码,在帮助下http://dbp-consulting.com/tutorials/debugging/linuxProgramStartup.html http://dbp-consulting.com/tutorials/debugging/linuxProgramStartup.html .
这是汇编代码的某些部分。
080482e0 <__libc_start_main@plt>:
80482e0: ff 25 10 a0 04 08 jmp *0x804a010
80482e6: 68 08 00 00 00 push $0x8
80482eb: e9 d0 ff ff ff jmp 80482c0 <_init+0x2c>
Disassembly of section .text:
080482f0 <_start>:
80482f0: 31 ed xor %ebp,%ebp
80482f2: 5e pop %esi
80482f3: 89 e1 mov %esp,%ecx
80482f5: 83 e4 f0 and $0xfffffff0,%esp
80482f8: 50 push %eax
80482f9: 54 push %esp
80482fa: 52 push %edx
80482fb: 68 70 84 04 08 push $0x8048470
8048300: 68 00 84 04 08 push $0x8048400
8048305: 51 push %ecx
8048306: 56 push %esi
8048307: 68 ed 83 04 08 push $0x80483ed
804830c: e8 cf ff ff ff call 80482e0 <__libc_start_main@plt>
8048311: f4 hlt
8048312: 66 90 xchg %ax,%ax
8048314: 66 90 xchg %ax,%ax
8048316: 66 90 xchg %ax,%ax
8048318: 66 90 xchg %ax,%ax
804831a: 66 90 xchg %ax,%ax
804831c: 66 90 xchg %ax,%ax
804831e: 66 90 xchg %ax,%ax
080483ed <main>:
80483ed: 55 push %ebp
80483ee: 89 e5 mov %esp,%ebp
80483f0: b8 00 00 00 00 mov $0x0,%eax
80483f5: 5d pop %ebp
80483f6: c3 ret
80483f7: 66 90 xchg %ax,%ax
80483f9: 66 90 xchg %ax,%ax
80483fb: 66 90 xchg %ax,%ax
80483fd: 66 90 xchg %ax,%ax
80483ff: 90 nop
...
Disassembly of section .got:
08049ffc <.got>:
8049ffc: 00 00 add %al,(%eax)
...
Disassembly of section .got.plt:
0804a000 <_GLOBAL_OFFSET_TABLE_>:
804a000: 14 9f adc $0x9f,%al
804a002: 04 08 add $0x8,%al
...
804a00c: d6 (bad)
804a00d: 82 (bad)
804a00e: 04 08 add $0x8,%al
804a010: e6 82 out %al,$0x82
804a012: 04 08 add $0x8,%al
我的问题是;
在0x804830c中,调用了0x80482e0(我已经理解了前面的指令)。
在0x80482e0处,进程跳转到0x804a010。
在0x804a010中,指令为
...等待。刚出去? %al 里有什么,0x82 在哪里?我被困在这条线上了。
请帮忙....
*附注我是linux和操作系统的初学者。我正在学校课堂上学习操作系统概念,但仍然找不到如何学习正确的Linux汇编语言。我已经下载了英特尔处理器手册,但它太大了,无法阅读。谁能告诉我一些适合我的材料?谢谢。