Linker scripts之SECTIONS
1 Purpose
The linker script describes how the sections in the input files should be mapped into the output file, and control the memory layout of the output file.
2 Simple example
The simplest linker script has just one command: `SECTIONS'. Assume program consists only of code, initialized data, and uninitialized data. These will be in the `.text', `.data', and `.bss' sections, respectively.
A few common special sections are:
• .text -- Used for program code.
• .bss -- Used for uninitialized objects (global variables).
• .data -- Used for initialized non-const objects (global variables).
• .const -- Used for initialized const objects (string constants, variables declared const).
• .cinit -- Used to initialize C global variables at startup.
• .stack -- Used for the function call stack.
• .sysmem - Used for the dynamic memory allocation pool.
SECTIONS
{
. = 0x10000;
.text : { *(.text) }
. = 0x8000000;
.data : { *(.data) }
.bss : { *(.bss) }
}
The first line sets the value of the special symbol `.', which is the location counter. The location counter is then incremented by the size of the output section.
The second line defines an output section, `.text'. The expression `*(.text)' means all `.text' input sections in all input files.
Since the location counter is `0x10000' when the output section `.text' is defined, the linker will set the address of the `.text' section in the output file to be `0x10000'.
The remaining lines define the `.data' and `.bss' sections in the output file. The linker will place the `.data' output section at address `0x8000000'. After the linker places the `.data' output section, the value of the location counter will be `0x8000000' plus the size of the `.data' output section. The effect is that the linker will place the `.bss' output section immediately after the `.data' output section in memory.
3 SECTIONS command
The SECTIONS command tells the linker how to map input sections into output sections, and how to place the output sections in memory.
The format of the SECTIONS command is:
SECTIONS
{
sections-command
sections-command
...
}
Linker scripts之SECTIONS的更多相关文章
- 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 ...
- 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 ...
- linux内核的makefile.txt讲解
linux内核的linux-3.6.5\Documentation\kbuild\makefiles.txt Linux Kernel Makefiles This document describe ...
- Linux内核Makefile文件(翻译自内核手册)
--译自Linux3.9.5 Kernel Makefiles(内核目录documention/kbuild/makefiles.txt) kbuild(kernel build) 内核编译器 Thi ...
- Automake
Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...
- Linux Kernel的Makefile与Kconfig文件的语法
https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Introduction ------------ The c ...
- About Gnu Linker1
1 OverView ld combines a number of object and archive files, relocates their data and ties up symbol ...
- 使用GNU工具链进行嵌入式裸机开发
Embedded-Programming-with-the-GNU-Toolchain Vijay Kumar B. vijaykumar@bravegnu.org 翻译整理:thammer gith ...
随机推荐
- 单调队列 && 单调栈
单调队列 && 单调栈 单调队列 维护某个滑动区间的min or max,可用于dp的优化 以维护min为例,采用STL双端队列实现 每次加入元素x前 先检查队首元素==滑动后要删除的 ...
- Mysql [Err] 1118 - Row size too large
首先声明,对MySQL不懂,很多都不知道原因 设计了一个表,里面很多text字段,然后填进去的东西太多(用的是Python的MySQLdb),报错: _mysql_exceptions.Operati ...
- android自定义dialog布局
dialog使用系统自带的有时候不是很美观,就想要自己来设计一个dialog界面,以下就是可以设计的dialog界面: public class CustomDialog extends Dialog ...
- Hexo系列(一) 搭建博客网站
写在前面的话:本系列文章主要参考 Hexo官方说明文档,同时结合自己在使用过程中的一些心得体会,撷取下来,和大家分享分享.好,下面闲话不多说,马上开始我们的 Hexo 之旅吧 温馨提醒:博主使用的操作 ...
- Redis启动出错 noauth authentication required.
输入认证过的密码即可. 在命令行中运行: auth password
- 《奋斗吧!菜鸟》 第八次作业:Alpha冲刺 Scrum meeting 1
项目 内容 这个作业属于哪个课程 任课教师链接 作业要求 https://www.cnblogs.com/nwnu-daizh/p/11012922.html 团队名称 奋斗吧!菜鸟 作业学习目标 A ...
- 20150805-20150807 tradeDate-----python
1.创建数据库(strategy).表(trade_date 交易日) create database strategy default character set utf8 collate utf8 ...
- 0926mysql join的原理
转自 http://www.cnblogs.com/shengdimaya/p/7123069.html MySQL JOIN原理 先看一下实验的两张表: 表comments,总行数28856 表 ...
- [MGR——Mysql的组复制之单主模式 ]详细搭建部署过程
1,关于MySQL Group Replication 基于组的复制(Group-basedReplication)是一种被使用在容错系统中的技术.Replication-group(复制组)是由 ...
- Swift中文教程(二)基本运算符
1.基本运算符 运算符是一种特定的符号或表达式,用来检验.改动或合并变量.比如,用求和运算符+能够对两个数字进行求和(如let i = 1 + 2):略微复杂一点的样例有逻辑与操作符&& ...