/sys/i386/i386/locore.s分析笔记
2009-05-13 14:46:14来源:未知 阅读 ()
200 /**********************************************************************
201 *
202 * This is where the bootblocks start us, set the ball rolling...
203 *
204 */
205 NON_GPROF_ENTRY(btext)
从/boot/kernel/kernel中可以读出btext的链接地址:
# readelf -a /boot/kernel/kernel | grep btext
6870: c0458a30 0 FUNC GLOBAL DEFAULT 5 btext
26381: c0458a30 0 FUNC GLOBAL DEFAULT 5 btext
因此,在物理地址0x458a30处设置断点,单步跟踪locore.s中的初始化代码。程序运行至此
的cpu主要寄存器的内容如下:
rax: 0x00000000:00458a30 rcx: 0x00000000:a0200000
rdx: 0x00000000:000488a0 rbx: 0x00000000:00458a30
rsp: 0x00000000:0009e844 rbp: 0x00000000:00094884
rsi: 0x00000000:000610e4 rdi: 0x00000000:0005b9cc
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:00458a30
eflags 0x00000002
首先是向0x472写入0x1234,告知bios下次为热引导:
216 /* Tell the bios to warmboot next time */
217 movw $0x1234,0x472
构建一个新的栈帧:
220 /* Set up a real frame in case the double return in newboot is executed. */
221 pushl %ebp
222 movl %esp, %ebp
此时cpu主要寄存器的内容如下:
rax: 0x00000000:00458a30 rcx: 0x00000000:a0200000
rdx: 0x00000000:000488a0 rbx: 0x00000000:00458a30
rsp: 0x00000000:0009e840 rbp: 0x00000000:0009e840
rsi: 0x00000000:000610e4 rdi: 0x00000000:0005b9cc
r8 : 0x00000000:00000000 r9 : 0x00000000:00000000
r10: 0x00000000:00000000 r11: 0x00000000:00000000
r12: 0x00000000:00000000 r13: 0x00000000:00000000
r14: 0x00000000:00000000 r15: 0x00000000:00000000
rip: 0x00000000:00458a3c
eflags 0x00000002
将PSL_KRENEL赋给eflags:
224 /* Don't trust what the BIOS gives for eflags. */
225 pushl $PSL_KERNEL
226 popfl
PSL_KERNEL是在/sys/i386/include/psl.h中定义的:
60 /*
61 * The i486 manual says that we are not supposed to change reserved flags,
62 * but this is too much trouble since the reserved flags depend on the cpu
63 * and setting them to their historical values works in practice.
64 */
65 #define PSL_RESERVED_DEFAULT 0x00000002
66
67 /*
68 * Initial flags for kernel and user mode. The kernel later inherits
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
- NetBSD笔记 2009-05-13
- portupgrade笔记 2009-05-13
- Linux学习笔记 2009-05-13
- 分析squid的日志,罗列出一天最多的点击url 2009-05-13
- FreeBSD7 Apache2.2 PHP5 PostgreSQL8.3 Ports安装笔记 2009-05-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash