
更多内容可以加入Linux系统知识库套餐(教程+视频+答疑)
开学季,Linux驱动大全课程大促~~


一、链接脚本 vmlinux.lds
要分析 Linux 启动流程,同样需要先编译一下 Linux 源码,因为有很多文件是需要编译才会生成的。首先分析 Linux 内核的连接脚本文件 arch/arm/kernel/vmlinux.lds,通过链接脚本可以找到 Linux 内核的第一行程序是从哪里执行的。vmlinux.lds 中有如下代码:
492OUTPUT_ARCH(arm)
493ENTRY(stext)
494 jiffies = jiffies_64;
495 SECTIONS
496{
497/*
498 * XXX: The linker does not define how output sections are
499 * assigned to input sections when there are multiple statements
500 * matching the same input section name. There is no documented
501 * order of matching.
502 *
503 * unwind exit sections must be discarded before the rest of the
504 * unwind sections get included.
505 */
506/DISCARD/:{
507*(.ARM.exidx.exit.text)
508*(.ARM.extab.exit.text)
509
......
645}
第 493 行的 ENTRY 指明了了 Linux 内核入口,入口为 stext,stext 定义在文件arch/arm/kernel/head.S 中 , 因 此 要 分 析 Linux 内核的启动流程,就得先从文件arch/arm/kernel/head.S 的 stext 处开始分析。






