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 ...
随机推荐
- BZOJ 4278 [ONTAK2015]Tasowanie (后缀数组)
题目链接: https://www.lydsy.com/JudgeOnline/problem.php?id=4278 题解: 居然把后缀数组写成n^2的..我真厉害.. 想了无数种方法,最后发现就是 ...
- 00106_UDP通信
1.DatagramPacket (1)JDK中提供了一个DatagramPacket类,该类的实例对象就相当于一个集装箱,用于封装UDP通信中发送或者接收的数据: (2)在创建发送端和接收端的Dat ...
- 【codeforces 508A】Pasha and Pixels
[题目链接]:http://codeforces.com/contest/508/problem/A [题意] 让你在一个n*m的方格上给方格染色; 顺序给出染色的k个格子 如果在某一时刻 有一个2* ...
- 中国省市区地址三级联动插件---jQuery Distpicker
插件描述:distpicker是一款可以实现中国省市区地址三级联动jQuery插件.它使用简单,简单设置即可完成中国省市区地址联动效果. [官网]https://fengyuanchen.github ...
- ZooKeeper之初识
它是什么 俗称动物管理员,它使用java开发,开源,接口简单,高效,稳定的分布式系统,为其它分布式系统提供协调服务 为什么会存在? 开发分布式系统跟单机上做开发完全不同,碰到的问题完全不同,开发分布式 ...
- CF #316 DIV2 D题
D. Tree Requests time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...
- springmvc mybatis 分页插件 pagehelper
springmvc mybatis 分页插件 pagehelper 下载地址:pagehelper 4.2.1 , jsqlparser 0.9.5 https://github.com/pagehe ...
- 高仿QQ6.0之側滑删除
前两天已经完毕了高仿QQ6.0側滑和优化,今天来看下側滑删除的实现吧,假设有兴趣,能够去看下之前的两篇,仿QQ6.0側滑之ViewDragHelper的使用(一)和高仿QQ6.0側滑菜单之滑动优化(二 ...
- GTK经常使用控件之行编辑( GtkEntry )
行编辑,仅仅同意输入一行内容的控件.如password输入框. 行编辑的创建: GtkWidget *gtk_entry_new(void); 返回值:行编辑指针 设置行编辑内容的最大长度: void ...
- DOS命令将黑框中查询到的信息保存到TXT等文件里