【28系列DSP小结-2】cmd文件

来源:互联网 发布:上海日上免税店有mac 编辑:程序博客网 时间:2024/06/05 10:16
首先了解一下软件名称约定* project.pjt                 工程文件* program.c                 C语言源文件* program.asm            汇编语言源文件* filename.h                 C语言头文件* filename.lib               库文件* project.cmd              链接命令文件* program.obj             编译后的目标文件* program.out             在目标硬件(实验箱)上加载、调试、执行的文件

cmd文件

作用:分配片上存储空间

DSP输出目标文件中的最小单元是Section,section在存储映射上是连续的,各个section块之间相互独立。C语言程序编译后生成三个基本段:

.text 执行文件  .data 初始化数据  .ebss 未初始化数据

全部段可分为两种基本类型,未初始化段初始化段
初始化段存储执行代码或初始化数据,其中内容在这些块在程序装载是装入对应存储空间。

Initialized sections contain executable code or initialized data. The
contents of these sections are stored in the object file and placed in
TMS320C28x memory when the program is loaded. Each initialized section
is independently relocatable and may reference symbols that are
defined in other sections. The linker automatically resolves these
references.

未初始化段一般放在RAM中,这些段在目标文件中没有实际值,它们只是简单地在存储区中占据空间。程序在运行时利用这些空间来创建和存储数据。

Uninitialized sections reserve space in TMS320C28x memory; they are
usually placed in RAM. These sections have no actual contents in the
object file; they simply reserve memory. A program can use this space
at run time for creating and storing variables.

特定段名:

 - .text           存储程序代码和常量 - .cinit          C全局和静态变量的初始化值 - .pinit          启动时调用的结构表 - switch          存储执行switch的常数表格 - econst          22位const

未初始化段

 - .ebss       全局和静态变量存储地址(启动时由_c_int00从cinit复制) - .stack      栈空间 - esystem     堆空间

存储空间划分
MEMORY
memory指令将系统的存储空间进行划分,链接器只把程序存入配置过的存储区域。memory指令如下:

The general syntax for the MEMORY directive is:
MEMORY
{
[PAGE 0:] name 1 [( attr )] : origin = expression , length = expression [, fill = constant]
}

PAGE:  标识存储页,通常PAGE 0为程序空间,PAGE 1为数据空间;如果一个存储块没有指明PAGE,链接器将其当做PAGE 0。name: 存储区间名称attr: 属性    R:可读 W:可写 X:包含可执行代码 I:可被初始化origin:  起始地址length:  区间长度fill: 以字符填充该区间
MEMORY{PAGE 0 :   /* BEGIN is used for the "boot to SARAM" bootloader mode   */   BEGIN      : origin = 0x000000, length = 0x000002                RAMM0      : origin = 0x000002, length = 0x0003fe   RAML0      : origin = 0x008000, length = 0x001200   ...   PAGE 1 :    FLASH       : origin = 0x3F0000, length = 0x007F7F   BOOT_RSVD   : origin = 0x000400, length = 0x000080     /* Part of M1, BOOT rom will use this for stack */   RAMM1       : origin = 0x000480, length = 0x000380     /* on-chip RAM block M1 */   RAML1    : origin = 0x03F9200, length = 0x000D00}

SECTION

SECTIONS
{
name : [property [, property] [, property] … ]
}

每个section段都定义了out输出文件的一个输出块,一个段可能的属性有load:段的存储地址    load = 地址 or load > 地址run:段的运行地址    run = 地址 or run > 地址Input section:输入段    {input_sections}fill value:填充未初始化区域
   RamFuncs    :    LOAD = FLASH_ABCD, PAGE = 0                   /* Used by InitFlash() in SysCtrl.c */                    {                            Encoder_IncEnc.obj(.text)                    }                         RUN = L0SARAM,     PAGE = 0                                        /*相当于把地址值赋给runstart*/                         LOAD_START(_RamFuncs_loadstart),                         LOAD_END(_RamFuncs_loadend),                         RUN_START(_RamFuncs_runstart)
0 0