Cannot Use a Pointer to Call Function in a Static OverlayLast reviewed: July 17, 1997Article ID: Q58098 |
2.x 3.x 4.x 5.0x 5.10 5.11 5.13 5.15 5.20 5.3x 5.50 5.60
MS-DOS
kbtool
The information in this article applies to:
SUMMARYMicrosoft LINK does not support using a function pointer to call a function in a static overlay unless the function is called from the same overlay. If an overlaid function is called from the root or from a different overlay, it cannot be called through a pointer.
MORE INFORMATIONStatic overlays do not support calling an overlaid function indirectly through a pointer because the loader determines the address of the indirect function at load time. Versions of Microsoft LINK prior to version 5.3 support only static overlays. LINK version 5.3 introduced MOVE (Microsoft Overlaid Virtual Environment) dynamic overlays that do support calling an overlaid function through a pointer. Microsoft LINK versions 5.3x, 5.5, and 5.6 can still generate static overlays using the /OLD[OVERLAY] command line switch. The same issue of lack of support for calling an overlaid function through a function pointer still applies to these later versions. In an application with static overlays, the linker recognizes a normal function call (one that does not take place through a pointer) and places an interrupt call into the executable file instead of the function call. At run time, the interrupt gives control to the overlay manager which determines if the correct overlay is loaded in memory, loads the overlay if necessary, and calls the function. Because the object module contains a fixup record for the function call, the linker can set the interrupts as required. On the other hand, when an application uses a function pointer, the compiler creates a fixup record for the address to which the pointer refers. However, the fixup record does not indicate that the record provides the address for a function. Therefore, if the function is linked as an overlay, the linker does not call the overlay manager but performs a standard fixup. Consequently, if an application calls a function located in an overlay that is not loaded in memory, the overlay manager is not called to load the overlay. Instead, the application passes control to the random data located at the destination address and disaster can easily result.
|
Additional reference words: kbinf 4.06 4.07 4.10 5.01.20 5.01.21 5.02 5.03
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |