Home |
RTTarget-32 Programming Manual Running Win32 Programs without Win32 The Locate Process in Detail Running a Program on the Target Compiling and Linking with On Time RTOS-32 |
The Locate Process in DetailThis section contains some information about how RTLoc relocates the application. This information helps to better understand the sequence used to map program items and why the sequence of Locate commands can be important. RTLoc processes all commandline parameters from left to right. Each configuration file is processed before the rest of the command line. If no configuration file is specified, the default configuration file (Application.cfg) is processed after the command line. Next, RTLoc will attempt to process map files for all modules with segment numbers given in their Locate Section or Locate NTSection commands. The respective sizes of such sections are calculated in this step. The .EXE file of the main program and all DLLs are read. The sizes of all sections that don't have a size yet are calculated now. The image of each section is also saved. If Locate PageTable was specified, the page table is created and - if no size was given - its size is determined from the Region commands. Since RAM remapping and the creation of virtual regions take place later, the size found may be too small. If boot code is included, the boot code .EXE file is read and the size of the boot code and data is determined. If a Reserve command was given, the reserved application image file is read and its application header retrieved. RTLoc will go through all program entities of the reserved application and look for overlaps between it and regions defined for the current locate process. If overlaps are found, the first available address of the region is set to the first byte following the overlap. This algorithm is used because RTLoc does not support fragmented regions. Each region is filled from low to high addresses. RTLoc maintains a high water mark for each region to which the next entity can be mapped. Thus, if the reserved application and the current application have been built using different Region commands, memory can be wasted. In addition to processing the program entities of the reserved application, RTLoc will also analyze the imported page table (if any) and merge it with the current page table. The application header is initialized and its size is calculated. If any entities are mapped to virtual regions, the sizes of the pseudo entities to hold the physical data of these entities are determined. The next step involves mapping all entities except copies and entities without a fixed size (e.g., stack and heap are not located yet if no size was specified for them). All entities are allocated to their respective regions in the sequence the entities were created. All program entities that can contain fixups are now mapped and fixups are applied. The method depends on whether Locate Section or Locate NTSection is used. With Locate NTSection, all fixups are simply incremented by the difference between the image base address of the PE file and the image base assigned by RTLoc. For Locate Section, RTLoc determines the location and target of each fixup location and adds the difference of the PE-file's target location and RTTarget-32's target location to the fixup. All DLL references are also resolved in this step. If any Locate Copy commands are present, the copies are created (with compression, if appropriate) and mapped now. Again, their sequence is observed in the mapping process. If stack and heap have not been mapped and do not map to the FillRAM region, they are mapped now. If a FillRAM command was specified, RTLoc will now go through all regions and look for pages of RAM which are not used and have Assign access. Such pages are remapped and appended to the region given in the FillRAM command. Note that this process may require the page table to grow, which can lead to an error at this stage. If the stack and heap are still unmapped, they are processed now. Since this is performed after RAM remapping, they can benefit from the enlarged region that has received all unused pages.
|