This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| dev:crosscompiler:linker32 [2014/02/10 13:21] – external edit 127.0.0.1 | dev:crosscompiler:linker32 [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Linker32 ====== | ||
| - | The linker32 is written for 32 bit platforms. The linker performs various tasks like: | ||
| - | * Place code in the memory | ||
| - | * Create type descriptors and constant blocks | ||
| - | * Create system table | ||
| - | * Create target image | ||
| - | |||
| - | ===== Initialization ===== | ||
| - | As a first step the linker must be initialized with the method //init()//. What happens is: | ||
| - | * Determine size of // | ||
| - | * Search segments for the system table | ||
| - | * Delete previous target image | ||
| - | |||
| - | ===== Create Constant Block ===== | ||
| - | Each class has a constant block. Certain interfaces need a reduced constant block and arrays just need a type descriptor, see [[.: | ||
| - | * Header (base, size, ...) | ||
| - | * Global pointer list | ||
| - | * Type descriptor | ||
| - | * String pool | ||
| - | * Constant pool | ||
| - | * Checksum | ||
| - | [{{ .: | ||
| - | The //const pool// contains values of type //float// and //double// which are not placed directly into the code. After all elements are added the // | ||
| - | When the system ist starting up, the [[..: | ||
| - | |||
| - | In the compiler the constant block is modeled as linked list of '' | ||
| - | * **'' | ||
| - | * **'' | ||
| - | * **'' | ||
| - | * **'' | ||
| - | * **'' | ||
| - | * **'' | ||
| - | |||
| - | ==== Type Descriptor ==== | ||
| - | The structure and purpose of the [[Type Descriptor]] is described separately. | ||
| - | |||
| - | ==== String pool ==== | ||
| - | The string pool holds the constant strings of a class. They are stored as follows (also see [[strings|Strings]]: | ||
| - | [ tag ] | ||
| - | [ stringClassAddress ] | ||
| - | [ Object | ||
| - | [ nofChars | ||
| - | [ chars ] | ||
| - | [ ⋮ ] | ||
| - | The characters of the string are stored in 2-Byte-Unicode. | ||
| - | |||
| - | ==== Constant Pool ==== | ||
| - | The constant pool holds the constants of a class. Currently we only store there floating point numbers (//float// and // | ||
| - | |||
| - | **Example: | ||
| - | [40490FDB] 3.1415927 (float) | ||
| - | [401921FB] 6.283185307179586 (double) | ||
| - | [54442D18] | ||
| - | |||
| - | |||
| - | ===== Calculate Size and Offsets ===== | ||
| - | [{{ .: | ||
| - | Before the memory map can be fixed, a couple sizes and offsets must be calculated for each class: | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | ===== Create System Table ===== | ||
| - | The linker assembles a system table for the whole system. This table must be loaded to a prefixed address in the target system and holds information for the [[..: | ||
| - | - The system runs from the flash | ||
| - | - The system runs from the RAM. | ||
| - | - The base system is in the flash. Further classes are later loaded into the RAM. This case needs two system tables. The flash holds a system table which contains only classes which are present in the flash. The system table in the RAM must hold all classes. IMPORTANT This feature is not implemented yet IMPORTANT | ||
| - | |||
| - | In the compiler the system table is modeled as list. as elements it uses the same blocks as for the constant block. Additionally '' | ||
| - | |||
| - | The structure of the system table is: | ||
| - | [{{ .: | ||
| - | |||
| - | First, the class constructor of the class kernel must be found. For this, the class name of the kernel is fetched from the configuration and the method //< | ||
| - | |||
| - | The references to the constant blocks are assembled as follows. First come the classes with class constructors. These classes are already sorted in correct order as described in [[class_initialization]]. Classes without initialization follow afterwards. Arrays and interfaces have no constant block and are not listed. The exception to this rule are interfaces with class constructor, | ||
| - | |||
| - | ===== Fix Memory Map ===== | ||
| - | [{{ .: | ||
| - | In this step the code is placed in the memory, as well as the class variables and the constants. First, each class is assigned a memory segment for the code ('' | ||
| - | Now, the base address of each used segment can be determined. \\ | ||
| - | IMPORTANT System methods with offsets given by the configuration must be placed in their appropriate segments. This leads to holes. Such holes could be eliminated by a more efficient allocation, which is currently not done. | ||
| - | |||
| - | ===== Calculate Absolute Addresses ===== | ||
| - | First, the addresses of static fields are fixed. For this the linker traverses the list '' | ||
| - | |||
| - | ===== Refresh Constant Block ===== | ||
| - | After calculating absolute addresses the constant block has to be refreshed. | ||
| - | |||
| - | ===== Create Global Constant Table ===== | ||
| - | This table holds constants which do not belong to a specific class. To give an example: Certain constants are needed to convert an //int// to a //float//. | ||
| - | |||
| - | ===== Create Target Image ===== | ||
| - | Finally, the target image is put together. For each method of each class and for each constant block (one for each class, array or interface) a target segment is created and inserted into a list. | ||
| - | |||