Keil Logo

Sections, Classes, and Groups

A section is a contiguous area of memory generated from code or data defined in a source module. Each section has a type, class, group, and a name. Sections are usually related to the hardware configuration. Therefore, portions of programs stored in ROM are in separate sections from the portions stored in RAM. Sections generated by the Keil C166 Compiler are given names which are composed of a prefix and the name of the source module.

A class is an arbitrarily ordered collection of sections that share a common attribute. The purpose of a class is to allow manipulation of a number of sections using only the class name. For instance, the near data objects from all modules in a program are combined into the NDATA class while the far constant objects are combined into the FCONST class.

A group is a shorthand which is used to reference a collection of sections that all reside within one data page (for data groups) or segment (for code groups). Groups define address-range limits for their references sections. Two group types are supported: CGROUP (code groups) and DGROUP (data groups). Groups are used by the linker to guarantee that classes within the group fit into the appropriate address range (16K for DATA or 64K for CODE) and that DPP register assignments are correctly performed in the startup code. The DPPUSE linker directive may be used to extend the address space possible for DATA groups.

Objects that the C166 Compiler generates (such as program code, program data, and constant data) are stored in sections that may be absolute or relocatable. The only exception is automatic variables that are stored on the USER STACK that is addressed by the R0 register. The compiler creates a separate section for each memory type used in the C source.

Section names created by the C166 Compiler are converted to and stored in uppercase and include a class-code and a module-name formatted as follows:

?class-code?module-name

Where

class-code is an abbreviation for the class type.
module-name is the name of the source file in which the object is declared.

The following table shows all possible section names with their associated class and group names. The class and group names are used by the linker to simplify address assignments and to ensure that objects from different modules are placed in valid address ranges.

Section Name Group Name Class Name Section Contents
?PR?module-name NCODE NCODE near function code
?PR?module-name FCODE far function code
?NC?module-name NCONST NCONST const near objects
?FC?module-name FCONST const far objects
?HC?module-name HCONST const huge objects
?XC?module-name XCONST const xhuge objects
?ND?module-name NDATA NDATA near objects with #pragma NOINIT
?ND0?module-name NDATA NDATA0 near objects with #pragma INIT
?SD?module-name SDATA SDATA sdata objects with #pragma NOINIT
?SD0?module-name SDATA SDATA0 sdata objects with #pragma INIT
?ID?module-name SDATA IDATA idata objects with #pragma NOINIT
?ID0?module-name SDATA IDATA0 idata objects with #pragma INIT
?BD?module-name SDATA BDATA bdata objects with #pragma NOINIT
?BD0?module-name SDATA BDATA0 bdata objects with #pragma INIT
?BI?module-name BIT bit objects with #pragma NOINIT
?BI0?module-name BIT0 bit objects with #pragma INIT
?FD?module-name FDATA far objects with #pragma NOINIT
?FD0?module-name FDATA0 far objects with #pragma INIT
?HD?module-name HDATA huge objects with #pragma NOINIT
?HD0?module-name HDATA0 huge objects with #pragma INIT
?XD?module-name XDATA xhuge objects with #pragma NOINIT
?XD0?module-name XDATA0 xhuge objects with #pragma INIT
?C_INITSEC Variable-initialization information
?C_MEMCLRSEC RAM zero-initialization information
?C_STARTUP_CODE ICODE Startup code for the C main function

Note

  • If the TINY memory model is used, no group names are assigned to the section names.
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.