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. python mysql连接池

    话不多说,直接撸代码 # coding=utf-8 from DBUtils.PooledDB import PooledDB import pymysql as mysql import trace ...

  2. Appium的ios配置

    automationName  text        XCUITest platformName             text          iOS platformVersion      ...

  3. S-HR系统流程

  4. 【习题 4-5 Uva1590】 IP Networks

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 假设从第i位开始有不一样的. 那么就把i+1..32位全都置0. 掩码的话类似.前i为全为1,后面32-i位全0. 尽量让后面的连续 ...

  5. 修改Xorg.conf配置显示分辨率

    修改Xorg.conf是件简单的事,配置文件结构简单,也没有复杂的语法,但是一但配置失败,后果是比较 严重的,,所以强烈建议每次修改之前做好备份工作. Xorg.conf一般位于/etc/X11/xo ...

  6. nginx配置文件使用

    nginx进程数,建议设置为等于CPU总核心数. worker_processes 8; 全局错误日志定义类型,[ debug | info | notice | warn | error | cri ...

  7. 模型概念--MVC-MVVM

    MVVM 第一个M是数据访问曾,第二个v是view视图页面,第三个vm是ViewModel视图模型

  8. axios 全攻略之基本介绍与使用(GET 与 POST)

    axios axios 是一个基于 Promise 的 HTTP 客户端,专门为浏览器和 node.js 服务 Vue 2.0 官方推荐使用 axios 来代替原来的 Vue request,所以这里 ...

  9. TensorFlow 便捷的实现机器学习 三

    TensorFlow 便捷的实现机器学习 三 MNIST 卷积神经网络 Fly Overview Enabling Logging with TensorFlow Configuring a Vali ...

  10. Mybatis结合Spring注解自己主动扫描源代码分析

    作为一个想做架构师的程序猿,必须是一个优秀的程序猿.在引入某一个框架的时候,必需要研究源代码,将新的开源框架的风险变为可控性. 1.Spring结合Mybatis最经常使用的配置. <!--理论 ...