Microsoft KB Archive/91722

{|
 * width="100%"|

Placing Application Data into a MOVE Overlay

 * }

Q91722

-

The information in this article applies to:


 * Microsoft LINK for MS-DOS, version 5.3

-

Page 604 of the Microsoft C/C++ version 7.0 &quot;Environment and Tools&quot; 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 module

This 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:

"LNK9208002" The article is titled &quot;LNK9208: L1101 From Unsupported Fixup to Target in Overlay&quot;

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 --


 * 1) include 

extern void overlay(void);

void main {  overlay; }

OVER.C --


 * 1) pragma data_seg(&quot;_CODE&quot;)


 * 1) include 

void overlay {  printf(&quot;This string comes from an overlay.\n&quot;); }

TEST.DEF

SEGMENTS main_text OVL:0 over_text OVL:1

Sample Code #2
* Compile options needed: /AL LINK command: sortdemo,,,graphics,sortdemo.def

SORTDEMO.C --

Modify the SORTDEMO.C example in C700\SAMPLES\SORTDEMO directory. Add the following line after the #include directives

#pragma data_seg(&quot;_CODE&quot;)

SORTDEMO.DEF

SEGMENTS 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 move" The article is titled &quot;LNK9208: L1101 From Unsupported Fixup to Target in Overlay&quot;

Additional query words: kbinf 5.30 MoveOverlay

Keywords : kb16bitonly

Issue type :

Technology : kbAudDeveloper kbZNotKeyword3 kbLINKSearch kbLINK530DOS