|
|
|
|
Combining Segments
A segment is a code or data block created by the compiler or
assembler from your source code. There are two basic types of
segments: absolute and relocatable.
-
An absolute segment resides at a fixed memory location
and may not be relocated or moved by the linker. Absolute segments
do not have names and are not combined with other segments. They
are copied directly to the output file.
-
A relocatable segment has a name and a type (as well as
other attributes shown in the table below). Two or more relocatable
segments with that have the same name are called partial segments.
They are considered to be part of the same segment and are combined
by the linker (even if they are created in separate source
files).
While processing program modules, the linker produces a table of
all segments. The linker stores the segment name, type, location
method, length, and base address and uses this information to combine
partial relocatable segments. When combining segments, the following
rules are observed:
-
All partial segments that share a common name must have the
same memory class. An error occurs if the types do not
correspond.
-
The length of the combined segments must not exceed the length
of the physical memory area.
-
The location method for each of the combined partial segments
must correspond.
The following segment attributes are used to determine how to
link, combine, and locate code or data in a segment.
| Attribute |
Description |
| Name |
Each relocatable segment has a name that is used
when combining segments from different program modules.
Absolute segments do not have names. |
| Memory Area |
The memory area identifies the address
space to which the segment belongs. The class may be
BIT, CODE, DATA, IDATA,
or XDATA. |
| Relocation Type |
The relocation type specifies the relocation
operations that may be performed by the linker. Valid
relocation types are AT address,
BITADDRESSABLE, INBLOCK, INPAGE,
INSEG, OFFS offset, and
OVERLAYABLE. |
| Alignment Type |
The alignment type specifies the alignment
operations that are performed by the linker. Valid alignment
types are BIT, BYTE, WORD, DWORD,
PAGE, BLOCK, and SEG. |
| Length |
The length attribute specifies the length of the
segment. |
| Base Address |
The base address specifies the first assigned
address of the segment. For absolute segments, the address is
assigned by the assembler or compiler. For relocatable
segments, the address is assigned by the linker. |
|
|
|