基于x86的Linux总动代码分析 小和作 主要目标文件的编译 ●vmlinux The actual objects are generated when descending. #make sure no implicit rule kicks in sIsort s(vmLinux-initl s(vnlinux-main]s(vnlinuz-lds):s(vmlinx-dirs) #Handle descending into subdirectories listed in s(vmlinux-dirs] Preset locale variables to speed up the build process,Limit locale tweaks to this spot to avoid wrong Language settings when running #nake menuconfig atc. Error messages still appears in the original language P0Y+=s(mlim任-dirs) s(vmlinux-dirs)prepare scripts ◆[Q]$[NE》$Eu41d)=8 wmlinux-dirs :s(patsubst \/,\s[filter s(init-yh s(init-n)\ s(core-y)s(cora nl s(drivers-y)s(drivers-m)\ (nat-y)sinet-n)$(Libs-yl (Libs-m)) ·不妨以core-y为例,观察体系相关和体系无关部分的代码是 如何被包含进来的 4口卡4回子1元电月只0 陈查兰(xlanchen@ustc.edu.cn) Linux操作系统分新
. . . . . . 基于x86的Linux启动代码分析 小结和作业 . 主要目标文件的编译 . . vmlinux ↓ ↓ ↓ 不妨以core-y为例,观察体系相关和体系无关部分的代码是 如何被包含进来的 陈香兰(xlanchen@ustc.edu.cn) Linux操作系统分析
基于x86的Li门ux总动代码分折 小结和作出 x86的启动文件 ●根据vmlinux-init找到head-y,init-y 。关于arch/x86/Makefile的引入 根Makefile中以include的方式包含了X86体系结构相关部分 的Makefile #Read arch specific Nakefile to set KBUILD_DEFCONFIG as needed. #KBUILD_DEFCONFIG may point out an alternative default configuration used for 'make defconfig' inctude $(srctreel/arch/s(SRCARCH)/Makefile export KBUILD_DEFCONFIG 。在这个Makefile中 161 head-y :arch/x86/kemel/head_BITS).o 162 head-y arch/x86/kemel/heads(BITS.0 163 head-y arch/x86/kemel/init_task.o 。其中,变量BITS为32或者64,我们只考隐32位的情况 。在根Makefile中 init-y :init/ ●可以看到vmlinux包含如下内容 ·i386/kernel/head.32.S等+ init/main.c init/version.o+ ·CORE_FILES+DRIVERS+ ·NETWORKS+LIBS 4日4021元电月00 陈香兰(xlanchen(@ustc.edu.cn】 Linux操作系统分新
. . . . . . 基于x86的Linux启动代码分析 小结和作业 . x86的启动文件 . . 根据vmlinux-init找到head-y, init-y 关于arch/x86/Makefile的引入 根Makefile中以include的方式包含了X86体系结构相关部分 的Makefile 在这个Makefile中 其中,变量BITS为32或者64,我们只考虑32位的情况 在根Makefile中 可以看到vmlinux包含如下内容 i386/kernel/head 32.S等 + init/main.c + init/version.o + CORE FILES + DRIVERS + NETWORKS + LIBS 陈香兰(xlanchen@ustc.edu.cn) Linux操作系统分析
基于x86的Linux启动代码分折析 小和件出 为便于阅读,了解关于命令输出的相关内容 Beautify output #Normally,we echo the whole command before executing it.By making that echo s(s(quiet)s(cmd)),we now have the possibility to set #s(quiet)to choose other fors of output instead,e.g. quiet_cmd_cc_o_c Compiling $(RELDIR)/$0 cmd_cc_a_c =(CC)$cf1ags)c00$× #If s(quiet)is empty,the whole command will be printed. If it is set to "quiet".only the short version will be printed. If it is set to "silent",nothing wil be printed at all,since the variable s(silent_cmd cc_o_c)doesn't exist. #A simple variant is to prefix commands with $(Q)-that's useful #for commands that shall be hidden in non-verbose mode. s(Q]1ns0:< w If KBUILD_VERBOSE equals 0 then the above command will be hidden. If KBUILD_VERBOSE equals 1 then the above command is displayed. ifeq (s(KBUILD_VERBOSE),1) quiet 0= else quietsquiet Q=0 endif 4日卡021元电月00 陈毒兰(xlanchen@ustc.edu.cn】 Linux操作系统分新
. . . . . . 基于x86的Linux启动代码分析 小结和作业 . 为便于阅读,了解关于命令输出的相关内容 . . 陈香兰(xlanchen@ustc.edu.cn) Linux操作系统分析
基于x86的Linux启动代码分析 小结和作业 make XXX ●若make install 在x86的Makefile中有install规则 。若make bzlmage/zlmage等,则要找到对应的目标然后进行 。bzlmage/zlmage可在arch/x86的Makefile中找到相应规则 。其他的zXXX/bzXXX也都依赖于boot下的zlmage/bzlmage ●它们最终都找到i386/boot/Makefile 4日卡4回21元电月只0 陈查兰(xlanchen@ustc.edu.cn) Linux操作系统分新
. . . . . . 基于x86的Linux启动代码分析 小结和作业 . make XXX 若make install 在x86的Makefile中有install规则 若make bzImage/zImage等,则要找到对应的目标然后进行 bzImage/zImage可在arch/x86的Makefile中找到相应规则 其他的zXXX/bzXXX也都依赖于boot下的zImage/bzImage 它们最终都找到i386/boot/Makefile 陈香兰(xlanchen@ustc.edu.cn) Linux操作系统分析