Chapter 11. memory allocation and load map

The linker places each section in memory based on the attributes of the section and the memory that is available, which is specified by the range command or by default. Each section has the following attributes:

Memory is allocated section by section. Typically, there is no way to control the order in which sections are allocated. However, sections are processed in the order in which they become known to the linker. A section is known when it appears in a sect command or is processed in an object module.

Sections are allocated in the following order:

  1. Each absolute or fixed section is placed in memory at its specified address. This includes placing the start section at zero. The memory required for the section must be a part of memory made available through the range command.

  2. Each ranged section is placed in memory within the specified range. This range must lie within a portion of memory specified by the range command.

  3. All remaining sections are allocated as follows: As each section is processed, the ranges for its memory type are examined to find enough free space to allocate the section. Each range is examined in order. The first space large enough to contain the section is used. At this point, the memory allocated is marked "used." If not enough memory is available to allocate the section, an error message is displayed. inpage sections must be placed between address xx00 and xxFE (see assembly .sect directive). For SMALL and MEDIUM memory models, ROM sections must not cross 4K boundaries (see assembly model control and .chip directive).

The load map shows the following information (see Section 3.4 for example):

If there is an overlap between sections, this is indicated in the Memory Order Map by the message ** memory overlap ** next to the overlapping section(s).

If sections do not fit in memory, their address is shown in the Section Table as "_ _ _ _ ." Also, no object code is generated for these sections.