Sections

You can also add user sections, the recommended syntax to assign objects to a user defined section is __declspec(sectname).

Listing: Syntax __declspec(sectname)
void __declspec(bootsection) _bootoperation ( void );
#pragma define_section sectname [objecttype] istring [ustring] 
[addrmode] [accmode] [align]

where,

<objecttype> binds sectname to object type

code_type executable object code

data_type non-constant data size > small data threshold

sdata_type non-constant data size <= small data threshold

const_type constant data

string_type string data

all_types all code and data (default)

<sectname> identifer by which this user-defined section is referenced in the source, i.e. via #pragma section <sectname> begin or __declspec(<sectname>)

<istring> section name string for -initialized- data assigned to <section> e.g. .data (also applies to uninitialized data if <ustring> is omitted)

<ustring> elf section name for -uninitialized- data assigned to <section>

<addrmode> one of the following, which indicates how the section is addressed:

standard target-specific standard method

near_absolute 16-bit absolute address

far_absolute 32-bit absolute address

near_code 16-bit offset from target-specific code base register

far_code 32-bit offset from target-specific code base register

near_data 16-bit offset from target-specific data base register

far_data 32-bit offset from target-specific data base register

<accmode> one of the following, which indicates the attributes of the section:

R readable

RW readable and writable

RX readable and executable

RWX readable, writable and executable

<align> section alignment, default is 0 => (optimize for speed || aligncode) ? 4 : 2

The ELF sections have default configurations, these can be modified by redefining them. Compiler generated sections:

  "text",sect_text, ".text", 0, "standard", "RX", 0   
  "data",sect_data, ".data", ".bss", "standard", "RW", 0   
  "sdata",sect_sdata, ".sdata", ".sbss", "near_data", "RW", 0   
  "const",sect_const, ".rodata", 0, "standard", "R", 0   
  "string",sect_string, ".rodata", 0, "standard", "R", 0   
  "abs",sect_abs, ".abs", 0, "far_absolute", "R", 0   

This section contains the following topics: