Placing Application Data into a MOVE OverlayLast reviewed: July 17, 1997Article ID: Q91722 |
5.30 | 5.30
MS-DOS | WINDOWS
kbtool kbcode kberrmsg
The information in this article applies to:
Page 604 of the Microsoft C/C++ version 7.0 "Environment and Tools" manual indicates that an application can place data into a Microsoft Overlaid Virtual Environment (MOVE) overlay by declaring a code segment that contains the data and placing the segment into an overlay. To declare data in a code segment, use a __based allocation, #pragma data_seg, or an assembler module. However, when the fast compiler option (/f) is used, placing data into a code segment may create a file that hangs or does not process its data correctly. This incorrect behavior is caused by the method the fast compiler uses to generate code to access data and the method that the linker performs fixups. To address this situation, use the optimizing compiler (/f-). The optimizing compiler detects that data has been placed into a code segment and loads the segment value from the CS register. In some cases, version 5.3 of the Microsoft Linker (LINK) issues the following error message:
L1101: invalid object moduleThis can occur without regard to the version of the compiler in use. Updating to LINK version 5.31.009, which is available in the patches for C/C++ version 7.0, will most likely prevent error L1101 from occurring. For more information, search in the Microsoft Knowledge Base on the following word:
LNK9208002The article is titled "LNK9208: L1101 From Unsupported Fixup to Target in Overlay" The design of the MOVE assumes that run-time relocations are performed relative to the root. In other words, an overlay cannot contain any base fixups to segments other than the root. However, the fast compiler generates run-time relocations that are relative to the current overlay. In most cases, compiling with the optimizing compiler ensures that data in an overlaid code segment generates only offset fixups. LINK version 5.31.009 may issue a new warning message, L4059. The PATCH.TXT file, distributed with the C/C++ patches, documents the L4059 warning as follows:
New warning L4059 has been added. It occurs if code contains far segment references to overlaid targets. These references are resolved correctly only if they are code references (not data references).Because the linker does not have the information to determine whether a symbol is for code or data, the warning is given for both code references and data references. The following code samples demonstrate creating a data overlay. NOTE: Using the technique below is not guaranteed to work for every kind of data allocation and it has not been fully tested. In the first example, the fast compile option (/f) is used, the printf() statement in the overlay() function fails to print the string placed into the code segment with the #pragma data_seg. LINK 5.31.009 produces an L4059 warning message. The string is printed correctly when the optimizing compiler (/f-) is used. The second example generates an L1101 error message with LINK 5.3. However, LINK 5.31.009 does not generate an L1101 error.
Sample Code #1
/* * Compile options needed: /f /AL * LINK command: main over, test.exe,,, test.def */ MAIN.C
#include <stdio.h>extern void overlay(void);
void main(){ overlay();}
OVER.C#pragma data_seg("_CODE")
#include <stdio.h> void overlay(){ printf("This string comes from an overlay.\n");}
TEST.DEFSEGMENTS main_text OVL:0 over_text OVL:1
Sample Code #2
/* Compile options needed: /AL LINK command: sortdemo,,,graphics,sortdemo.def */ SORTDEMO.CModify the SORTDEMO.C example in C700\SAMPLES\SORTDEMO directory. Add the following line after the #include directives
#pragma data_seg("_CODE") SORTDEMO.DEFSEGMENTS sortdemo_text OVL:1 For more information on using the SEGMENTS statement in MOVE overlay syntax, search in the Microsoft Knowledge Base on the following words:
link and overlay and moveThe article is titled "LNK9208: L1101 From Unsupported Fixup to Target in Overlay"
|
Additional reference words: kbinf kbinf 5.30 MoveOverlay
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |