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 ...
随机推荐
- Day 22 面向对象编程
面向对象基础 面向对象编程(抽象) 对象:特征和技能的结合体 面向对象编程:一个个对象进行交互 优点:扩展性非常强 缺点:逻辑非常复杂 类与对象 类(类别):一系列具有相同特征和技能的对象 现实世界中 ...
- 【剑指Offer】39、平衡二叉树
题目描述: 输入一棵二叉树,判断该二叉树是否是平衡二叉树.这里的定义是:如果某二叉树中任意结点的左.右子树的深度相差不超过1,那么它就是一棵平衡二叉树. 解题思路: 首先对于本题我们要 ...
- html表单练习
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- malloc实现机制、缓冲机制、文件操作、mmap虚拟地址(day06)
一.malloc的实现机制(缓冲机制) 库函数跟系统调用之间的关系 什么是缓冲? 内存分配的原理. 封装 函数A的实现代码中调用了函数B.函数B的功能是函数A主要的功能,这样就说函数A封装了函数B. ...
- CF135E Weak Subsequence (计数问题)
题目传送门 题目大意:对于给定字符集大小k,求有多少个字符串满足它的最长[既是子串又是弱子序列]的长度为w: 神仙计数题 打表发现,对于字符串S而言,它的最长[既是子串又是弱子序列],一定存在一个对应 ...
- iptables 实现内网转发上网
介绍 通过iptables做nat转发实现所有内网服务器上网. 操作 首先开启可以上网的服务器上的内核路由转发功能.这里我们更改/etc/sysctl.conf 配置文件. [root@web1 /] ...
- 2、在1.VMware虚拟机上安装ubantu系统
1.新建新的虚拟机系统 2.使用自定义高级安装 3.选择下一步操作 4.选择稍后安装 4.因为我们要安装的是Linux的发行版本ubuntu,所以这里选择Linux(L),版本是Ubuntu 64位, ...
- QT的creator中图示
不同的开发工具显示class和相关的用不同的图标表示.但大同小异.但对于QT的creator中图示确实不太好分.看图一目了然.
- [bzoj1660][Usaco2006 Nov]Bad Hair Day_单调栈
Bad Hair Day bzoj-1660 Usaco-2006 Nov 题目大意:n头牛站成一列,每头牛向后看.f[i]表示第i头牛到第n头牛之间有多少牛,使得这些牛都比i矮,且中间没有比i高的牛 ...
- Dagger2使用攻略
Dagger2使用攻略 Dagger 2 是 Square 的 Dagger 分支,是一种依赖注入框架.眼下由 Google 接手进行开发,Dagger2是使用代码自己主动生成和手写代码来实现依赖注入 ...