next up previous contents
Next: Hardware Initialization Code Up: Link Time Context Previous: Linker Sections

Memory Map

UCR naturally expects to be stored in memory. It needs at least one segment of ram, that can contain all the sections, but it perfectly well handles a segment of ROM for rommable memory. UCR directly makes use of no more then two segments of contiguous memory.

Table 2: Required Linker Symbols
etext End of the text section. The initial data image starts here.
__DTOR_TABLE__ Locations of nil terminated arrays of function pointers. These are the static initializers and destructors for the linked program.
2p3inThe following symbols must be together is a single contiguous RAM segment.  
bdata Beginning of the initialized data.
edata End of initialized data, beginning of uninitialized data.
end End if uninitialized data, beginning of heap space.
end_heap End of heap.
2cThe main stack can go anywhere in RAM.  

ucr_start() expects to be able to find at link time the symbols described in Table . The Memory between end and end_heap is used as the default heap. It doesn't have to be the actual size of the memory, as long as it is not more. The uCR startup will initialize the heap to use these bytes as heap space and new and <delete operators will then use this memory. Other heap spaces can be created with uCR functions, but will not affect the default heap.

The bstack and estack symbols bound the stack of the initial thread. This initial thread is used to call initializers, and main. Pointers to these symbols are placed in the THREAD structure for the main thread, but are otherwise unused by uCR proper.

If the processor has a stack that grows downward toward low addresses (the m680x0 does, the i960 does not) then the main thread and the heap space may overlap, as long as the top of the stack is at or above the top of the heap. The heap handler is designed to allow for this as long as the stack and heap do not collide. If the processor stack grows up, then this magic does not work.

The memory between bdata and edata comes from the .data section of the fully linked coff file. ucr_start() uses these symbols to know where to copy the initial image. The initial values for the initialized data starts at etext. If &etext == &bdata, then the image is not copied at all.

The system may have other memory segments accessible by other means. UCR makes no direct use of them, nor does it prevent their use.

next up previous contents
Next: Hardware Initialization Code Up: Link Time Context Previous: Linker Sections
Stephen Williams