On Time RTOS-32 Documentation
Welcome
RTTarget-32
RTTarget-32 Programming Manual
Introduction
Running Win32 Programs without Win32
The i386 Microprocessor
RTLoc: Locating a Program
Running a Program on the Target
Cross Debugging
Using an IDE
The RTTarget-32 API
Demo Programs
Advanced Topics
Choosing a Locate Method
Running with or without Paging
Running at CPL 0 or 3
Installing Hardware Interrupt Handlers
Catching NULL Pointer Assignments
Catching Stack Overflows
Running without Run-Time System
Avoid Repeated Downloads
Configuration for Debug and Release Builds
Using Data Compression
Using DLLs through RTLoc
Using Rtt32dll.dll
Linking Rtt32.lib into the EXE
Using a Custom System DLL
Utility MakeDef
Differences from Win32
Using Microsoft Run-Time System DLLs
Loading DLLs through a File System
RAM File System
Installable File System
Multithread Applications
Using the MetaWINDOW Graphics Library
Using the 387 Emulator
Using Non-Volatile Memory
APIC Mode
Multiprocessor Applications
Custom MP Floating Pointer Structure
RTVmf-32
RTRth-32
Performance Optimizations
Compiling and Linking with On Time RTOS-32
Redistributable Components of RTTarget-32
RTLoc Error Messages
RTTarget-32 Reference Manual
RTKernel-32
RTFiles-32
RTIP-32
RTPEG-32
RTUSB-32
|
Using DLLs through RTLoc
The RTTarget-32 locator RTLoc supports the DLL command which adds DLLs to an application image. Both static references to DLL exported functions and dynamic linking using LoadLibrary and GetProcAddress are supported. Loading DLLs as files on the target is supported if a file system is used. For details about loading DLLs through a file system, see section Loading DLLs through a File System.
To use DLLs successfully, a thorough understanding of Win32's DLL mechanism is mandatory. If you are not familiar with terms such as import library, DLL exports, DLL imports, static DLL references, LoadLibrary, GetProcAddress, DllEntryPoint, or DEF files, please consult your compiler's documentation before trying to use RTTarget-32's DLL support.
To successfully use DLLs located into a program's image, the following prerequisites must be satisfied:
- For each DLL to be used, a separate DLL command must appear in the configuration file.
- All code and data sections of all modules must be mapped using separate Locate Section or Locate NTSection commands.
- For each module (EXE or DLL) which statically imports DLL entrypoints, the .idata section must be mapped with Locate Section or Locate NTSection commands. RTLoc will issue warning messages if this is not the case.
- For each module whose exported entrypoints must be available to GetProcAddress at run-time, the .edata section must be mapped with Locate Section or Locate NTSection commands.
- The RTTarget-32 library Rtt32.lib must be linked into exactly one module (either the main program or one of the DLLs). The preconfigured DLL Rtt32dll.dll may be used for this purpose. All RTTarget-32 native API and Win32 emulation functions which are referenced by other modules must be exported using a module definition file (DEF file).
- Any module which needs to call an RTTarget-32 native API function must define symbol RTT32DLL before including header file RTTARGET.H and must link import library Rtt32dll.lib instead of Rtt32.lib. For Delphi programs, access to the RTTarget-32 API is available through unit RTTarget.
In addition, it is recommended to link only one run-time system, preferably into the main EXE. Multiple run-time systems are supported, but may lead to very inefficient heap memory usage, especially when no paging is used. DLLs without a run-time system can be produced with RTTarget-32's special startup code C0rttd.obj. For optimal heap management in multi-module applications, it is recommended to use RTTarget-32's alternate heap manager RTTHeap in all DLLs and the main EXE. RTTHeap will insure that only one memory manager is used for all modules.
Advantages of Using DLLs
- Programs and DLLs which do not need access to RTTarget-32's native API can be binary compatible with Win32. For example, the DLLDemo example program shipped with RTTarget-32 consists of four modules: Dlldemo.exe, Lib1.dll, Lib2.dll, and Rtt32dll.dll. The application can be executed under Win32 without relinking.
- Projects can be composed of modules developed with different compilers and even programming languages. For example, RTTarget-32's Delphi support relies on Pascal programs using RTTarget-32's run-time support implemented with a DLL written in C and assembler.
- DLLs which were not developed for RTTarget-32 can be used as long as these DLLs do not call Win32 API functions not supported by RTTarget-32.
- Reduced download times. Although applications with DLLs are typically larger, repeated downloads during software development can be accelerated if code modifications do not affect all modules. In this case, unmodified modules are not downloaded again.
Disadvantages of Using DLLs
- The complexity of an application can increase significantly. Most applications will need custom linker definition files.
- Memory requirements increase because more memory is lost in section alignment.
- Application image size and memory requirements increase due to redundant code in several modules.
- If several run-time systems are used, heap memory is potentially used less efficiently.
The following sections describe several different configuration options available.
Advanced Topics
Using Data Compression
Using Rtt32dll.dll
Linking Rtt32.lib into the EXE
Using a Custom System DLL
Utility MakeDef
Differences from Win32
Using Microsoft Run-Time System DLLs
Loading DLLs through a File System
|