1.makefile分析
$(TOPDIR)/makefile
|
|-----> include $(obj)/include/config.mk 确定板子环境
| ||
| V
|----------> 136 确定 CROSS_COMPILE
|
|----------> 186 include $(TOPDIR)/config.mk
| |
| |------------------------------> 112 include $(OBJTREE)/include/autoconf.mk 导入配置变量
| |
| |-------------------------------> 145 确定 链接脚本
| |
| |--------------------------------> 200 确定 TEXT_BASE
| |
|
|-----------> 确定 OBJS, LIBS,目标和规则
|
|-----------> 2500 进行配置
2. mkconfig 分析
创建符号链接,让编译时使用对应板子环境的目录。
创建 include/config.mk 记录 make 配置信息,给以后的 make 用
创建 include/config.h 让编译使用 x210_sd 配置信息 (开发板厂商添加)
3. 链接脚本分析
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm") /*OUTPUT_FORMAT("elf32-arm", "elf32-arm", "elf32-arm")*/ OUTPUT_ARCH(arm) ENTRY(_start) SECTIONS { . = 0x00000000; // 指定连接首地址为 0x00000000 ,注意又指定了 TEXT_BASE ,而 TEXT_BASE 优先级更高 . = ALIGN(4); // 对齐 .text : // text 段需要注意顺序,由于bl0只能加载16kb,所以让负责重定位的代码先执行。 { cpu/s5pc11x/start.o (.text) cpu/s5pc11x/s5pc110/cpu_init.o (.text) board/samsung/x210/lowlevel_init.o (.text) cpu/s5pc11x/onenand_cp.o (.text) cpu/s5pc11x/nand_cp.o (.text) cpu/s5pc11x/movi.o (.text) common/secure_boot.o (.text) common/ace_sha1.o (.text) cpu/s5pc11x/pmic.o (.text) *(.text) } . = ALIGN(4); .rodata : { *(.rodata) } . = ALIGN(4); .data : { *(.data) } . = ALIGN(4); .got : { *(.got) } __u_boot_cmd_start = .; // 自定义段 .u_boot_cmd : { *(.u_boot_cmd) } __u_boot_cmd_end = .; . = ALIGN(4); .mmudata : { *(.mmudata) } . = ALIGN(4); __bss_start = .; .bss : { *(.bss) } _end = .; }