[uboot学习笔记(一)]u-boot.lds文件分析

本文深入解析了U-Boot的链接脚本u-boot.lds,包括其配置、架构选择、代码段定义以及地址映射,详细阐述了如何通过链接脚本控制U-Boot在目标板上的运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*
 * (C) Copyright 2002-2004
 * Gary Jennejohn, DENX Software Engineering, <gj@denx.de>
 *
 * See file CREDITS for list of people who contributed to this
 * project.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 */

/**********************************************************************
*uboot version: 2009.08
*board version: freescale imx28
*uboot flie   : u-boot.lds
*uboot链接脚本 ,指定生成可执行文件的各个代码段链接地址及标号
*path:  \board\freescale\mx28_evk\u-boot.lds
*
*Makefile:
*/config.mk-->/board/freescale/mx28_evk/config.mk-->
*/board/freescale/mx28_evk/u-boot.lds
**********************************************************************/


OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)        /*指定输出的平台arm*/
ENTRY(_start)           /*指定uboot输出可执行文件起始代码段*/
SECTIONS
{
    . = 0x00000000;     /*ld最终链接时候,会被-Ttext $(TEXT_BASE)更新*/
                        /*生成的uboot.bin链接地址都是从TEXT_BASE开始*/
                        /*uboot分两个阶段(flash/ram)             */
                        /*flash阶段,程序实际从0地址开始执行,但程序的*/
                        *链接地址是从TEXT_BASE开始,第一个阶段代码执行*/
                        /*都是相对寻址,所以即使链接地址不对应执行地址也不会出错*/
                        /*LDFLAGS += -Ttext $(TEXT_BASE) 定义在顶层目录的config.mk*/
                        /*TEXT_BASE = 0x41008000 在board/freescale/mx28_evk/config.mk定义*/
    . = ALIGN(4);       /*4字节对齐*/
    .text :             /*定义代码段*/
    {                   /*start.o链接在text段最前*/
        cpu/arm926ejs/start.o   (.text)  
        *(.text)        /*其他.o文件链接在start.o后面*/
    }

    . = ALIGN(4);       /*只读数据段*/
    .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }

    . = ALIGN(4);       /*数据段*/
    .data : { *(.data) }

    . = ALIGN(4);
    .got : { *(.got) }

    . = .;
    __u_boot_cmd_start = .; /*uboot自定义命令存储段*/
    .u_boot_cmd : { *(.u_boot_cmd) }
    __u_boot_cmd_end = .;

    . = ALIGN(4);
    __bss_start = .;        /*bss段起始*/
    .bss (NOLOAD) : { *(.bss) . = ALIGN(4); }
    _end = .;               /*bss结束地址*/
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值