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的更多相关文章

  1. Linker scripts之MEMORY

    1 MEMORY command The MEMORY command describes the location and size of blocks of memory in the targe ...

  2. Linker scripts之Intro

    1 Intro Every link is controlled by a linker script. The main purpose of the linker script is to des ...

  3. 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 ...

  4. linux内核的makefile.txt讲解

    linux内核的linux-3.6.5\Documentation\kbuild\makefiles.txt Linux Kernel Makefiles This document describe ...

  5. Linux内核Makefile文件(翻译自内核手册)

    --译自Linux3.9.5 Kernel Makefiles(内核目录documention/kbuild/makefiles.txt) kbuild(kernel build) 内核编译器 Thi ...

  6. Automake

    Automake是用来根据Makefile.am生成Makefile.in的工具 标准Makefile目标 'make all' Build programs, libraries, document ...

  7. Linux Kernel的Makefile与Kconfig文件的语法

    https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt Introduction ------------ The c ...

  8. About Gnu Linker1

    1 OverView ld combines a number of object and archive files, relocates their data and ties up symbol ...

  9. 使用GNU工具链进行嵌入式裸机开发

    Embedded-Programming-with-the-GNU-Toolchain Vijay Kumar B. vijaykumar@bravegnu.org 翻译整理:thammer gith ...

随机推荐

  1. PAT_A1119 Pre- and Post-order Traversals

    Source: PAT A1119 Pre- and Post-order Traversals (30 分) Description: Suppose that all the keys in a ...

  2. Python爬虫:HTTP协议、Requests库(爬虫学习第一天)

    HTTP协议: HTTP(Hypertext Transfer Protocol):即超文本传输协议.URL是通过HTTP协议存取资源的Internet路径,一个URL对应一个数据资源. HTTP协议 ...

  3. 【数据结构】4.1图的创建及DFS深度遍历(不完善)

    声明:本代码仅供参考,根本就不是正确代码(至少在我看来,有很多BUG和不完美的地方) 图的存储方式选择为邻接表,并且headNode只是来存储一个链表的Node首地址额 总之这个代码写的很垃圾呀很垃圾 ...

  4. [51Nod 1301] 集合异或和 (dp)

    传送门 Solution 一道比较好的dp题 想了半天组合数QAQ 首先要知道的是 A<B一定是B有一位是1且A的这位是0且前面都相等 那么肯定是要枚举这一位在哪里然后求出方案数 方案数考虑类似 ...

  5. SQL中的条件判断语句(case when zhen if,ifnull)用法

    简介: case具有两种格式.简单case函数和case搜索函数.这两种方式,可以实现相同的功能.简单case函数的写法相对比较简洁,但是和case搜索函数相比,功能方面会有些限制,比如写判定式.还有 ...

  6. Shell入门基础

    Shell的Helloworld #!/bin/bash echo "helloworld taosir" 执行方式 方式一:用 bash 或 sh 的相对或绝对路径(不用赋予脚本 ...

  7. vue项目初始化结构

  8. HDU 4518

    整理一下思路,明天再写... 这道题,其实就是求包含大于10的斐波那切数字的第K(K是斐波那契数)个数.注意到斐波那契数的爆炸性增长,所以在范围 内的符合要求的F数并不多吧.比如求第K个F数,那么,前 ...

  9. 用Thinphp发送电子邮件的方法

    好长时间没有动php了,突然想用thinkphp发送电子邮件,可是查阅了书籍都写的非常乱.没有继续看下去.这里找到了一个比較好的方法: 第一步:首先我们要引入一个外部类库:Mail.class.php ...

  10. QUERY_REWRITE_INTEGRITY

    QUERY_REWRITE_INTEGRITY Property Description Parameter type String Syntax QUERY_REWRITE_INTEGRITY = ...