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 ...
随机推荐
- Flask - 内置Session
目录 Flask - 内置Session 基本用法 给视图添加装饰器验证 Flask - 内置Session Flask中的Session非常的奇怪,他会将你的SessionID存放在客户端的Cook ...
- 编写who命令
第一个版本: /* who1.c - a first version of the who program * open, read UTMP file, and show results. */ # ...
- 团体程序设计天梯赛-练习集L1-006. *连续因子
L1-006. 连续因子 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 一个正整数N的因子中可能存在若干连续的数字.例如630 ...
- LA 4329 Ping pong
#include <iostream> #include <cstring> #include <cstdio> using namespace std; ; ; ...
- hdu 5170 精度控制
众所周知,GTY是一位神犇,为了更好的虐场,他从来不写数学作业而是去屠题,他的数学老师非常不爽,但由于GTY每次考试都AK,她也不能说什么,有一天老师在黑板上写了四个数——a,b,c,da,b,c,d ...
- FOJ2250 不可能弹幕结界
Problem 2250 不可能弹幕结界 Time Limit: 1000 mSec Memory Limit : 65536 KB Problem Description 咲夜需要穿过一片弹幕 ...
- 从SQL Server到MySQL,近百亿数据量迁移实战
从SQL Server到MySQL,近百亿数据量迁移实战 狄敬超(3D) 2018-05-29 10:52:48 212 沪江成立于 2001 年,作为较早期的教育学习网站,当时技术选型范围并不大:J ...
- js 实现栈的结构
js实现一个栈的数据结构 首先了解一下什么是栈,栈是一个后进先出的一种数据结构,执行起来效率比较高. 对于栈主要包括一些方法,弹出栈pop(),弹出栈顶元素,并删除该元素:压入栈push(),向栈中压 ...
- Python基础操作-集合
在Python set是基本数据类型的一种集合类型,它有可变集合(set())和不可变集合(frozenset)两种.创建集合set.集合set添加.集合删除.交集.并集.差集的操作都是非常实用的方法 ...
- Spring MVC-集成(Integration)-生成XML示例(转载实践)
以下内容翻译自:https://www.tutorialspoint.com/springmvc/springmvc_xml.htm 说明:示例基于Spring MVC 4.1.6. 以下示例说明如何 ...