zoukankan      html  css  js  c++  java
  • 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
           ...
         }
    
    
  • 相关阅读:
    【转】关于GRIB数据的处理
    [转载]国际gis遥感杂志
    【转】linux后台运行和关闭、查看后台任务
    OpenXML: excel 插入BarChart图表
    利用.Net Framework2.0 zip压缩、解压 string 数据
    C# 常见面试题(2)
    'String or binary data would be truncated' error message
    Openxml: 导出excel 设置 cell的格式
    OpenXML: Asp.net利用OpenXML 导出Excel.
    C#中文和UNICODE字符转换方法
  • 原文地址:https://www.cnblogs.com/mengdie/p/4364042.html
Copyright © 2011-2022 走看看