转自网络
分析过程:
查看arch/arm/Makefile下的第一个目标为all: zImage
找到以zImage作为目标的规则:
zImage Image xipImage bootpImage uImage: vmlinux
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
这个规则中命令执行的目录为$(boot)= arch/arm/boot,那么读取arch/arm/boot下的Makefile找到了这个Makefile中的第一条规则targets := Image zImage xipImage bootpImage uImage
(1)查看arch/arm/boot下的Makefile中的规则:
$(obj)/Image: vmlinux FORCE
$(call if_changed,objcopy)
@echo ' Kernel: $@ is ready'
要生成非压缩的内核Image,依赖的文件是vmlinux, 根据顶层Makefile中的规则:vmlinux的生成需要文件$(head-y),在arch/arm/Makefile下定义了
$(head-y) := arch/arm/kernel/head$(MMUEXT).o arch/arm/kernel/init_task.o
由此可以看出的Image 的入口程序为 Kernel的head.S
(2)查看arch/arm/boot下的Makefile中的规则:
$(obj)/zImage: $(obj)/compressed/vmlinux FORCE
$(call if_changed, objcopy)
@echo ' Kernel: $@ is ready'
可知压缩的内核zImage的依赖体是$(obj)/compressed/vmlinux
查看arch/arm/boot/compressed/Makefile中两条规则:
targets := vmlinux vmlinux.lds piggy.gz piggy.o $(FONT) head.o misc.o head.o misc.o $(OBJS)
$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/$(HEAD) $(obj)/piggy.o /
$(addprefix $(obj)/, $(OBJS)) FORCE
$(call if_changed,ld)
@:
其中$(HEAD):=head.o
有上述两条规则可知:zImage 的入口程序即arch/arm/boot/compressed/head.S
(3)查看arch/arm/boot下的Makefile中的另外两条规则:
$(obj)/bootp/bootp: $(obj)/zImage initrd FORCE
$(Q)$(MAKE) $(build)=$(obj)/bootp $@
@:
$(obj)/bootpImage: $(obj)/bootp/bootp FORCE
$(call if_changed,objcopy)
@echo ' Kernel: $@ is ready'
bootpImage的组成部分为bootp, bootp的组成部分为zImage和initrd
查看arch/arm/boot/bootp/下的Makefile的规则
$(obj)/bootp: $(src)/bootp.lds $(addprefix $(obj)/, init.o kernel.o initrd.o) FORCE
$(call if_changed,ld)
@:
$(obj)/kernel.o: arch/arm/boot/zImage FORCE
$(obj)/initrd.o: $(INITRD) FORCE
从上面的规则可知:bootpImage 的入口程序即arch/arm/boot/bootp/init.S