Everything

.SECTION


Indicate to the assembler the start of section.

[Syntax]

Symbol field
Mnemonic field
Operand field
Comment field
[label:]
.SECTION
section-name, relocation-attribute [, ALIGN=absolute-expressions]
[; comment]

[Function]

-

The .SECTION directive indicates to the assembler the start of a section (no separation of code and data).

[Description]

-

This directive defines a program or data that has a coherent set of functions in a program.
This directive is valid until another section definition directive appears.

-

When an instruction that outputs a label or an object code is used at the beginning of a source program before this directive appears, a relocatable code section is generated as a default section.
In this case, the section name will be ".text", and the relocation attribute is set to "TEXT".

-

.SECTION directive can specify the start address of a section by specifying AT, DATA_AT, BSS_AT, or BIT_AT as the relocation attribute in the operand field.
The section start address can also be specified through the .ORG directive.
In this case, the section name will be "the section name specified in the operand field" + "_AT" + "specified address (hexadecimal notation in uppercase letters without prefix (0x or 0X) or suffix (h or H)".

-

The following shows the relocation attributes that can be specified.
If an attribute that is not listed below is used, an error will occur.

Table 5.15

Relocation Attributes

Relocation Attribute

Description Format

Default Section Name

Explanation

Default Value of Alignment ConditionNote 1

CALLT0

CALLT0

.callt0

Allocates a section between addresses 0x00080 and 0x000BF in the code flash areaNote 2 with the start address set to an even address.

2

TEXT

TEXT

.text

Allocates a section between addresses 0x000C0 and 0x0FFFF in the code flash areaNote 2.

1

TEXTF

TEXTF

.textf

Allocates a section between addresses 0x000C0 and 0xEFFFF in the code flash areaNote 2.

1

TEXTF_UNIT64KP

TEXTF_UNIT64KP

.textf_unit64kp

Allocates a section with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3.

2Note 4

CONST

CONST

.const

Allocates a section in the mirror source areaNote 2 with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3.

2

CONSTF

CONSTF

.constf

Allocates a section in the code flash areaNote 2 with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3.

2

SDATA

SDATA

.sdata

Allocates a section for data having initial values in the saddr areaNote 2 with the start address set to an even address.

2

SBSS

SBSS

.sbss

Allocates a section for data having no initial values in the saddr areaNote 2 with the start address set to an even address.Note 8

2

SBSS_BIT

SBSS_BIT

.sbss_bit

Allocates a section for bits having no initial values in the saddr areaNote 2 with the start address set to an even address. The optimizing linker links this section in byte units and assumes the relocation attribute as SBSS.Note 8 Note 9

2

DATA

DATA

.data

Allocates a section for data having initial values between addresses 0xF0000 and 0xFFFFF in the RAM areaNote 2 with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3.

2

BSS

BSS

.bss

Allocates a section for data having no initial values between addresses 0xF0000 and 0xFFFFF in the RAM areaNote 2 with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3.Note 8

2

BSS_BIT

BSS_BIT

.bss_bit

Allocates a section for bits having no initial values between addresses 0xF0000 and 0xFFFFF in the RAM areaNote 2 with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3. The optimizing linker links this section in byte units and assumes the relocation attribute as BSS.Note 8 Note 9

2

DATAF

DATAF

.dataf

Allocates a section for data having initial values with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3.

2

BSSF

BSSF

.bssf

Allocates a section for data having no initial values with the start address set to an even address so that it does not extend across a boundary of 64 Kbytes - 1Note 3.

2

ATΔaddress

AT absolute- expressionNote 5

None

Allocates a section at a specified address.

1 (fixed)

DATA_ATΔaddress

DATA_AT absolute- expressionNote 5

None

Allocates a section for data having initial values at a specified address.

1 (fixed)

BSS_ATΔaddress

BSS_AT absolute- expressionNote 5

None

Allocates a section for data having no initial values at a specified address.Note 8

1 (fixed)

BIT_ATΔaddress

BIT_AT absolute- expressionNote 5

None

Allocates a section for bits having no initial values at a specified address. The optimizing linker links this section in byte units and assumes the relocation attribute as BSS_AT.Note 8 Note 11

1 (fixed)

OPT_BYTE

OPT_BYTE

.option_byteNote 6

This attribute is dedicated to the user option byte setting and on-chip debugging settingNote 7.

The size is fixed to 4 bytes

1 (fixed)

SECUR_ID

SECUR_ID

.security_idNote 6

This attribute is dedicated to the security ID settingNote 7.

Machine-language instructions cannot be written in this section.

The size is fixed to 10 bytes.

1 (fixed)

Note 1.

The alignment condition can be modified through the .ALIGN directive.

Note 2.

For the code flash area, mirror area, RAM area, and saddr area, see the user's manual of the device. For the RAM area, note that only the on-chip RAM allocated to an address range from 0xF0000 to 0xFFFFF is supported.

Note 3.

Allocation beyond a boundary of 64 Kbytes - 1 is prohibited by default.

Note 4.

To guarantee correct access to 16-bit data, the alignment condition value is set to "2".

Note 5.

If the specified absolute expression is illegal or its value is outside the range from 0x00000 to 0xFFFFF, an error will occur.

Note 6.

This is a special section and the section name must not be changed (the name is fixed).

Note 7.

For addresses where the option byte, on-chip debugging, and security ID settings are allocated, see the user's manual of the device.

Note 8.

The two sections with the same name and different relocation attributes SBSS and SBSS_BIT, relocation attributes BSS and BSS_BIT, or relocation attributes BSS_AT and BIT_AT are processed as a single consecutive section in the assembler.

Note 9.

The section is output to the object file with the relocation attribute of SBSS, and the optimizing linker allocates the section with the relocation attribute of SBSS.

Note 10.

The section is output to the object file with the relocation attribute of BSS, and the optimizing linker allocates the section with the relocation attribute of BSS.

Note 11.

The section is output to the object file with the relocation attribute of BSS_AT, and the optimizing linker allocates the section with the relocation attribute of BSS_AT.

-

The section name setting cannot be omitted.

-

The relocation attribute setting cannot be omitted.

-

The following characters are usable in section names.

-

Alphanumeric characters (0-9, a-z, A-Z)

-

Special characters (@, _, .)

-

You can change the default alignment condition by specifying the ALIGN parameter. For the .ALIGN directive, specifying a larger value than that specified in the ALIGN parameter results in an error. [V1.10.00 or later]

[Example]

To define section ".text" having the TEXT attribute.

.SECTION        .text , TEXT
NOP

 

To define section ".data" having the DATA attribute.

.SECTION        "data", DATA
.DB2            0x1

 

To define section "EX" having the DATA_AT attribute with address 0xf2000 specified.

The section name will be set to "EX_ATF2000".

.SECTION        EX, DATA_AT     0xf2000
.DS             4