Keil Logo

SEGMENTS Linker Directive

Abbreviation

SE

Arguments

SEGMENTS (segment-name 〚(address)〛 〚, ...〛)
SEGMENTS (segment-name 〚(LAST)〛 〚, ...〛)
SEGMENTS (segment-name 〚(ALIGN(n))〛 〚, ...〛)
SEGMENTS (segment-name (execute) [〚!〛〚storage〛] 〚, ...〛)

Default

None.

µVision

Options — LX51 Locate — User Segments.

Description

The SEGMENTS directive allows specifying:

  • The absolute memory location for a segment.
  • The segment order in memory.
  • The alignment of a segment.
  • Special ROM (SROM) Handling allows SEGMENT content to execute and store at different addresses.

Note

  • The LX51 Linker allows using wildcards in segment names.

Specifying the Memory Location for a Segment

The following SEGMENTS directive specifies the absolute segment location in memory:

SEGMENTS (segment-name 〚(address)〛 〚, ...〛)

Where

segment-name is the name of the segment.
address is the beginning or ending address of the segment. If the address begins with a carat character ('^'), then the address represents the ending address of the segment. Subsequent segments will not be allocated below that address.

Specifying the Order of Segments in Memory

The following SEGMENTS directive specifies the order of segments in memory:

SEGMENTS (segment-name1 (address1) [, segment-nameX 〚, ...〛])

Where

segment-name1 is the name of the starting segment. This segment is located at the lowest possible address in its memory class.
segment-nameX are the names of subsequent segments. These segments are located in the order of their definition.
address1 is the address of segment-name1. Subsequent segments will not be allocated below that address.

Using the LAST Parameter

The SEGMENTS directive below locates the segment as the last segment in its memory class. These segments are located after all the other segments have been located.

SEGMENTS (segment-name 〚(LAST)〛 〚, ...〛)

Where

segment-name is the name of the segment.
LAST specifies that this segment is the last segment.

Note

  • An explicit address specification with previous segment names serves as base address for following segments. When the LAST segment should be placed before this base address, specify it before in the SEGMENTS directive.

Specifying the Minimal Alignment of a Segment

This SEGMENTS directive defines a minimal alignment for the named segment.

SEGMENTS (segment-name 〚(ALIGN(n)〛 〚, ...〛)

Where

segment-name is the name of the segment.
ALIGN(n) specifies the alignment with n as a power of 2.

 

  • If the specified segment has already an alignment defined from the compiler or assembler, then the larger of both is taken.

Specifying Special ROM (SROM) Segments

Using the following form of the SEGMENTS directive specifies Special ROM Handling to define different storage and execution addresses.

SEGMENTS (segment-name (execute) [〚!〛〚storage〛] 〚, ...〛)

Where

segment-name is the name of the segment.
execute is the execution address of the segment. The segment must be copied from the storage address to the execution address by the application program before it can be executed.
! specifies that the linker should not reserve memory at the execute address for the segment. This is useful when you have several SROM segments that execute from the same memory space.
storage is the storage address of the segment. If the storage address is not specified, the segment is stored in the SROM memory class.
See Also

CLASSES

Example

The following example places the ?DT?A and ?DT?B segments at 28h and 30h in DATA memory:

LX51 A.OBJ,B.OBJ SEGMENTS (?DT?A(D:0x28),?DT?B(D:0x30))

The following example specifies the order for the ?DT?A, ?DT?B, and ?DT?C segments. These segments start at the beginning of the memory class (the DATA class in this example). All other segments in the DATA class are located AFTER these segments.

LX51 A.OBJ,B.OBJ,C.OBJ SEGMENTS(?DT?A,?DT?B,?DT?C)

The following example places the ?PR?FUNC2?B segment in code bank 0 and the ?PR?FUNC2?A segment in code bank 1 at address 8000h.

LX51 BANK0 {A.OBJ}, BANK1 {B.OBJ} &
     SEGMENTS(?PR?FUNC2?B (B0:), ?PR?FUNC1?A (B1:0x8000))

The following example locates the ?DT?B segment as the last segment in the DATA class.

LX51 A.OBJ,B.OBJ,C.OBJ SEGMENTS(?DT?B(LAST))

The following example locates the ?PR?SUM?B segment so that it ends at address 0FF7FFFFh in the CODE class.

LX51 A.OBJ,B.OBJ SEGMENTS(?PR?SUM?B(^0xFF7FFFF))

The following example forces the ?XD?DAT_0 segment to begin at the next 64 Byte boundary.

LX51 A.OBJ,B.OBJ SEGMENTS(?XD?DAT_0(ALIGN(6)))

The following example assigns the ?PR?FUNC1?A segment an execution address of 4000h and a storage address of 0FF8000h. Memory is reserved at 4000h for the executable copy of this segment.

LX51 A.OBJ SEGMENTS(?PR?FUNC1?A(0x4000)[0xFF8000])

The following example assigns the ?PR?FUNC1?A segment an execution address of 4000h and a storage address of 0FF8000h. Memory is reserved at 4000h for the executable copy of this segment.

LX51 A.OBJ SEGMENTS(?PR?FUNC1?A(0x4000)[0xFF8000])

The following example assigns the ?PR?FUNC1?A segment an execution address of 2000h. The segment is stored in the SROM memory class. Memory is not reserved for the executable copy of this segment.

LX51 A.OBJ SEGMENTS(?PR?FUNC1?A(0x2000)[!])
  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.