openMSP430之Custom linker script
The use of the -mmcu switch is of course NOT mandatory. It is simply a convenient way to use the pre-existing linker scripts provided with the MSPGCC4 toolchain. However, if the peripheral address space is larger than the standard 512B of the original MSP430 (see the Advanced System Configuration section), a customized linker script MUST be provided.
  To create a custom linker script, the simplest way is to start from an existing one:
  • The MSPGCC(4) toolchain provides a wide range of examples for all supported MSP430 models (see “msp430/lib/ldscripts/” sub-directory in the MSPGCC(4) installation directory).
  • The openMSP430 project also provide a simple linker script example: 
    ldscript_example.x
From there, the script can be modified to match YOUR openMSP430 configuration:
  • In the text (rx) section definition, update the ORIGIN and LENGTH fields to match the PROGRAM MEMORY configuration.
  • In the data (rwx) section definition, update the ORIGIN field to match the PERIPHERAL SPACE configuration and the LENGTH field to match the DATA MEMORY configuration.
ldscript_example.x
/* Default linker script, for normal executables */
OUTPUT_FORMAT("elf32-msp430")
OUTPUT_ARCH("msp430")
MEMORY
{
data (rwx) : ORIGIN = 0x0200, LENGTH = 0x0080
text (rx) : ORIGIN = 0xf800, LENGTH = 0x0800-0x20
vectors (rw) : ORIGIN = 0xffe0, LENGTH = 0x20
}
REGION_ALIAS("REGION_TEXT", text);
REGION_ALIAS("REGION_DATA", data);
__WDTCTL = 0x0120;
__MPY = 0x0130;
__MPYS = 0x0132;
__MAC = 0x0134;
__MACS = 0x0136;
__OP2 = 0x0138;
__RESLO = 0x013A;
__RESHI = 0x013C;
__SUMEXT = 0x013E; SECTIONS
{
/* Read-only sections, merged into text segment. */
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
/* Internal text space. */
.text :
{
. = ALIGN();
*(.init)
*(.init0) /* Start here after reset. */
*(.init1)
*(.init2) /* Copy data loop */
*(.init3)
*(.init4) /* Clear bss */
*(.init5)
*(.init6) /* C++ constructors. */
*(.init7)
*(.init8)
*(.init9) /* Call main(). */
__ctors_start = . ;
*(.ctors)
__ctors_end = . ;
__dtors_start = . ;
*(.dtors)
__dtors_end = . ;
. = ALIGN();
*(.text)
. = ALIGN();
*(.text.*)
. = ALIGN();
*(.fini9) /* */
*(.fini8)
*(.fini7)
*(.fini6) /* C++ destructors. */
*(.fini5)
*(.fini4)
*(.fini3)
*(.fini2)
*(.fini1)
*(.fini0) /* Infinite loop after program termination. */
*(.fini)
} > text
.rodata :
{
. = ALIGN();
*(.rodata .rodata.* .gnu.linkonce.r.*)
. = ALIGN();
} > text
_etext = .; /* Past last read-only (loadable) segment */
.data : AT (ADDR (.text) + SIZEOF (.text) + SIZEOF (.rodata) )
{
PROVIDE (__data_start = .) ;
. = ALIGN();
*(.data)
. = ALIGN();
*(.gnu.linkonce.d*)
. = ALIGN();
_edata = . ;
} > data
PROVIDE (__data_load_start = LOADADDR(.data) );
PROVIDE (__data_size = SIZEOF(.data) );
.bss SIZEOF(.data) + ADDR(.data) :
{
PROVIDE (__bss_start = .) ;
*(.bss)
*(COMMON)
PROVIDE (__bss_end = .) ;
_end = . ;
} > data
PROVIDE (__bss_size = SIZEOF(.bss) );
.noinit SIZEOF(.bss) + ADDR(.bss) :
{
PROVIDE (__noinit_start = .) ;
*(.noinit)
*(COMMON)
PROVIDE (__noinit_end = .) ;
_end = . ;
} > data
.vectors :
{
PROVIDE (__vectors_start = .) ;
*(.vectors*)
_vectors_end = . ;
} > vectors
/* Stabs for profiling information*/
.profiler : { *(.profiler) }
/* Stabs debugging sections. */
.stab : { *(.stab) }
.stabstr : { *(.stabstr) }
.stab.excl : { *(.stab.excl) }
.stab.exclstr : { *(.stab.exclstr) }
.stab.index : { *(.stab.index) }
.stab.indexstr : { *(.stab.indexstr) }
.comment : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug : { *(.debug) }
.line : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo : { *(.debug_srcinfo) }
.debug_sfnames : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges : { *(.debug_aranges) }
.debug_pubnames : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info : { *(.debug_info) *(.gnu.linkonce.wi.*) }
.debug_abbrev : { *(.debug_abbrev) }
.debug_line : { *(.debug_line) }
.debug_frame : { *(.debug_frame) }
.debug_str : { *(.debug_str) }
.debug_loc : { *(.debug_loc) }
.debug_macinfo : { *(.debug_macinfo) }
PROVIDE (__stack = ORIGIN(data) + LENGTH(data));
PROVIDE (__data_start_rom = _etext) ;
PROVIDE (__data_end_rom = _etext + SIZEOF (.data)) ;
}
openMSP430之Custom linker script的更多相关文章
- A Sample Linker Script
		
from:http://www.hertaville.com/a-sample-linker-script.html A sample script file that will work with ...
 - Linux Kernel系列三:Kernel编译和链接中的linker script语法详解
		
先要讲讲这个问题是怎么来的.(咱们在分析一个技术的时候,先要考虑它是想解决什么问题,或者学习新知识的时候,要清楚这个知识的目的是什么). 我在编译内核的时候,发现arch/arm/kernel目录下有 ...
 - 链接脚本(Linker Script)用法解析(一) 关键字SECTIONS与MEMORY
		
1.MEMORY关键字用于描述一个MCU ROM和RAM的内存地址分布(Memory Map),MEMORY中所做的内存描述主要用于SECTIONS中LMA和VMA的定义. 2.SECTIONS关键字 ...
 - 链接脚本(Linker Script)应用实例(一)使用copy table将函数载入到RAM中运行
		
将函数载入到RAM中运行需要以下三个步骤: (1)用编译器命令#pragma section "<section name>" <user functions&g ...
 - 链接脚本(Linker Script)用法解析(二) clear_table & copy_table
		
可执行文件中的.bss段和.data段分别存放未赋初值的全局变量和已赋初值的全局变量,两者的特点分别为: (1).bss段:①无初值,所以不占ROM空间:②运行时存储于RAM:③默认初值为0 (2). ...
 - GNU linker script,ld script,GNU链接脚本
		
https://blog.csdn.net/itxiebo/article/details/50937412 https://blog.csdn.net/itxiebo/article/details ...
 - Linux Linker Script
		
先推荐两个网页: http://blog.csdn.net/muyuyuzhong/article/details/7755291 http://www.cnblogs.com/liulipeng/a ...
 - Linker scripts之MEMORY
		
1 MEMORY command The MEMORY command describes the location and size of blocks of memory in the targe ...
 - Linker scripts之Intro
		
1 Intro Every link is controlled by a linker script. The main purpose of the linker script is to des ...
 
随机推荐
- 2. Python中的基本输入、输出、格式化
			
本文利用的是Python 3.x版本,建议学习3.x版本 Python中的基本输入.输出.格式化 1. 输入 使用input([prompt])读取一行,将其转换为string类型并返回,input的 ...
 - CentOS7版本的新特性
			
综述 XFS 比 EXT 4更适合大文件处理,但消耗的CPU资源是EXT4的两倍 XFS 最大支持单文件16TB ,EXT4:50TB 最小1GB/建议每个逻辑CPU 1GB 逻辑CPU:核数,而非 ...
 - UCloud 的安全秘钥
			
UCloud 的安全秘钥(困难) 1200ms 262144K 每个 UCloud 用户会构造一个由数字序列组成的秘钥,用于对服务器进行各种操作.作为一家安全可信的云计算平台,秘钥的安全性至关重要.因 ...
 - springCloud学习-服务的注册与发现(Eureka)
			
1.小记 这段时间有空,把springcloud的知识整理一下,好记性不如烂笔头,也让自己对springcloud有个清晰的认识.此次的整理记录主要借鉴了这位大佬的博客 https://blog.cs ...
 - 记一次ruby的安装
			
1,下载rubyinstall 安装包及devkit包 登陆网站 :http://rubyinstaller.org/downloads/ 安装rubyinstall包时添加到环境变量 2,安装完in ...
 - TCP 连接状态
			
TCP/IP的设计者如此设计,主要原因有两个: 防止上一次连接中的包迷路后重新出现,影响新的连接(经过2MSL时间后,上一次连接中所有重复的包都会消失). 为了可靠地关闭TCP连接.主动关闭方发送的最 ...
 - war包结构
			
一个war包里面必含的两个目录是meta-inf和web-inf文件夹 一个war包里面必含的两个目录是meta-inf和web-inf文件夹 一个war包里面必含的两个目录是meta-inf和web ...
 - React Native Mac配置指南
			
步骤 http://facebook.github.io/react-native/docs/getting-started.html#content 依照React Native官网步骤一步步安装, ...
 - PHP array_diff_key()
			
定义和用法 array_diff_key() 函数返回一个数组,该数组包括了所有在被比较的数组中,但是不在任何其他参数数组中的键. 语法 array_diff_key(array1,array2,ar ...
 - Spark Streaming接收Kafka数据存储到Hbase
			
Spark Streaming接收Kafka数据存储到Hbase fly spark hbase kafka 主要参考了这篇文章https://yq.aliyun.com/articles/60712 ...