uboot的配置编译过程的链接文件u-bootlds的分析:
文件的来源:uboot中本来就存在的文件;
文件的路径:uboot/board/samsung/x210/u-boot.lds
文件被引用的地方:被uboot/config.mk文件引用,确定了具体的链接脚本
ifeq ($(CONFIG_NAND_U_BOOT),y)
LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot-nand.lds
else
LDSCRIPT := $(TOPDIR)/board/$(BOARDDIR)/u-boot.lds
下面是对其具体的分析:
1.指定了uboot程序的入口地址
ENTRY(_start)
相当于是.c文件中的main函数,经分析可知其实是调用执行start.s文件中的_start;
2.指定了代码段 数据段 bss段的起始地址:
SECTIONS
{
. = 0x00000000;
. = ALIGN(4);
.text :
{
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 = .;
}
和普通的lds链接文件的写法一样,但是由于uboot的启动分为两个阶段,第一阶段的程序必须放在16kb之前,所以对于那些指定为BL1阶段的执行代码必须放在前16KB内,那些代码会顺序执行来初始化DDR,初始化NAND和进行内存地址的重定位。而之后第二阶段的代码的位置没有太多的要求,只用将所有的text代码段放在BL1阶段的代码段之后就可以。
而链接脚本除了已有的四种存储段之外还可以供开发者进行自定义,而这里我们定义了我们的uboot的命令段u_boot_cmd。
追踪得知这个命令段被重命名:
#define Struct_Section __attribute__ ((unused,section (".u_boot_cmd")))
随便进行一个索引查找得知:定义时将变量后面加上段名,就会将这个变量放在属于我们自己设定的这个段里:
struct vfat_subentry {
unsigned char id; /* VSE_LAST pour la fin, VSE_MASK */
/* pour un VSE */
char text1 [VSE1SIZE * 2]; /* Caracteres encodes sur 16 bits */
unsigned char attribute; /* 0x0f pour les VFAT */
unsigned char hash1; /* toujours 0 */
unsigned char sum; /* Checksum du nom court */
char text2 [VSE2SIZE * 2]; /* Caracteres encodes sur 16 bits */
unsigned char sector_l; /* 0 pour les VFAT */
unsigned char sector_u; /* 0 pour les VFAT */
char text3 [VSE3SIZE * 2]; /* Caracteres encodes sur 16 bits */
} __attribute__ ((packed)) ;
END...................