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. Lua的热更新学习笔记_01

    热更新的的实现方式 1.使用lua脚本编写游戏的UI或者其他的逻辑 2.使用C#的反射技术 3.使用C#Light AssetBundle是什么? 1.unity提供一个资源更新技术,就是通过Asse ...

  2. echarts在地图上绘制散点图(任意点)

    项目需求:在省份地图上绘制散点图,散点位置不一定是哪个城市或哪个区县,即任意点 通过查询官网文档,找到一个与需求类似的Demo:https://www.echartsjs.com/gallery/ed ...

  3. 百度API的经历,怎样为多个点添加带检索功能的信息窗口

    不管我们要做什么样的效果,APIKey(密钥)都是不可缺少的要件,所以我们需要先去百度申请我们的APIKey!!! 伸手党,请直接到页面底部获取完整代码! 最近做一个门店查询的内容展示,考虑到用户直观 ...

  4. ro的session

    1.需要session管理器,根据需要选择: 2.需要一个login和logout的服务.注意:设定TRORemobteDataMedule.sessionmanager,但要设定TRORemobte ...

  5. fzoj 2113数位dp

    参考http://blog.csdn.net/xingyeyongheng/article/details/8785785 #include<stdio.h> #define ll lon ...

  6. [bzoj4084][Sdoi2015]双旋转字符串_hash

    双旋转字符串 bzoj-4084 Sdoi-2015 题目大意:给定两个字符串集合 S 和 T .其中 S 中的所有字符串长度都恰好为 N ,而 T 中所有字符串长度都恰好为 M .且 N+M 恰好为 ...

  7. [Angular] Performance Caching Policy - Cache First, Network Last

    If you want to cache API response by using angular service-worker, you can do it in: src/ngsw-config ...

  8. Red Hat Linux虚拟机与主机共享文件

    前置条件:linux上安装了VMware_Tool 参考https://dieyaxianju.cnblogs.com/EditPosts.aspx?postid=6829590 一.首先在本机上新建 ...

  9. 高可用技术工具包 High Availability Toolkit

    HighAvailabilityToolkit High Availability Toolkit includes several solutions by which achieving arch ...

  10. spring的bean管理(注解和配置文件混合使用)

    1.建三个类,在一个类中引用其他两个类 import javax.annotation.Resource; import org.springframework.beans.factory.annot ...