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 ...
随机推荐
- 国密SSL证书申请免费试用
沃通提供国密SSL证书免费申请试用服务,一次申请可同时签发SM2/RSA双算法证书,试用周期1个月,用于测试国密SM2 SSL证书的运行效果和SM2/RSA双证书部署效果. 试用产品:SM2/RSA双 ...
- vim/vi编辑器挂到后台ctrl + z
vim/vi编辑器通过CTRL+z将文件挂在到后台后,如果要再次进入,需通过jobs查看文件的序号,然后通过fg 序号进入文件进行编辑 (BaiduPictureToWord) [master@ins ...
- bos开发时,测试卡在登录界面解决
在BOS工作空间工程路径下新建sp文件夹,如在E:\bosworkspace8.2\Project_0\lib 新建sp文件夹E:\bosworkspace8.2\Project_0\lib\sp.然 ...
- Nginx Rewrite(伪静态)
一.作用: 实现URL地址改写. 二.语法: 例:rewrite ^/(.*) http://bbs.wangguangtao.com/$1 permanent; 注:应用位置server.loeat ...
- Laravel 5
遍历数组@foreach($brand as $v) <a href='/brandss/seeshops?id={{$v->id}}'><img src="/pub ...
- 对Django框架中Cookie的简单理解
概念的理解:首先Cookie和Session一样,是django中用于视图保持状态的方案之一.为什么要进行视图保留呢,这是因为浏览器在向服务器发出请求时,服务器不会像人一样,有记忆,服务器像鱼一样,在 ...
- [MySQL]--查询性能分析工具-explain关键字
explain显示了MySQL如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句. explain的使用方法很简单,只需要在select查询语句前面加上expl ...
- 在TOMCAT上手工生成及部署WAR包
以前是用ECLIPSE或是其它IDE自动生成,不明了. 这次手写JAVA,先生成CALSS来部署, 之后用WAR包来部署.(查了资料,好像直接用JAR来部署TOMCAT的WEB项目,不得行) 就上次生 ...
- mongodb--安全
安全和认证 mongodb和redis比较像,安全部分依赖于其所存在的环境 一定要把mongodb放在一个可信的环境下去运行,mongodb只能被web服务器所访问,禁止开外网端口访问mongodb, ...
- linux下select,poll,epoll的使用与重点分析
好久没用I/O复用了,感觉差点儿相同都快忘完了.记得当初刚学I/O复用的时候花了好多时间.可是因为那会不太爱写博客,导致花非常多时间搞明确的东西,依旧非常easy忘记.俗话说眼过千遍不如手过一遍,的确 ...