10.5.8. Special Section Types (DSECT, COPY, NOLOAD, and NOINIT)

You can assign the following special types to output sections: DSECT, COPY, NOLOAD, and NOINIT. These types affect the way that the program is treated when it is linked and loaded. You can assign a type to a section by placing the type after the section definition. For example:

SECTIONS
{
    sec1: load = 0x00002000, type =  DSECT  {f1.c.o}
    sec2: load = 0x00004000, type =  COPY   {f2.c.o}
    sec3: load = 0x00006000, type =  NOLOAD {f3.c.o}
    sec4: load = 0x00008000, type =  NOINIT {f4.c.o}
}
  • The DSECT type creates a dummy section with the following characteristics:

    • It is not included in the output section memory allocation. It takes up no memory and is not included in the memory map listing.

    • It can overlay other output sections, other DSECTs, and unconfigured memory.

    • Global symbols defined in a dummy section are relocated normally. They appear in the output module’s symbol table with the same value they would have if the DSECT had actually been loaded. These symbols can be referenced by other input sections.

    • Undefined external symbols found in a DSECT cause specified archive libraries to be searched.

    • The section’s contents, relocation information, and line number information are not placed in the output module.

    In the preceding example, none of the sections from f1.c.obj are allocated, but all the symbols are relocated as though the sections were linked at address 0x2000. The other sections can refer to any of the global symbols in sec1.

  • A COPY section is similar to a DSECT section, except that its contents and associated information are written to the output module. The .cinit section that contains initialization tables for the Arm C/C++ compiler has this attribute under the run-time initialization model.

  • A NOLOAD section differs from a normal output section in one respect: the section’s contents, relocation information, and line number information are not placed in the output module. The linker allocates space for the section, and it appears in the memory map listing.

  • A NOINIT section is not C auto-initialized by the linker. It is your responsibility to initialize this section as needed.