Microsoft KB Archive/42259

INF: Linker Switch /F Can Reduce Size and Increase Speed PSS ID Number: Q42259 Article last modified on 10-27-1994

2.03 2.10 3.00

WINDOWS

The Microsoft Linker /FARCALLTRANSLATION option switch (abbreviated /F) can reduce the size of an application developed for the Windows environment and can increase its execution speed.

When Windows loads an application, it creates a thunk (a relocation code fragment) for each far call. However, when an application makes a far call to a function in the same segment, no thunk is necessary. The /F switch instructs the Microsoft Linker to replace each far call to the same segment with the instructions NOP, PUSH CS, and CALL NEAR. The resulting near calls do not require a thunk, which saves memory space. Execution speed improves because the translated call does not execute the thunk code.

If the routine is called only from the same code segment, the application can save additional space and time by declaring the function as a near function. Doing so eliminates the NOP and PUSH CS instructions.

The “Microsoft CodeView and Utilities Software Development Tools for the MS-DOS Operating System” manual for Microsoft C versions 5.0 and 5.1 includes the following caveat regarding the /F option switch in Section 12.2.19 on page 277:

Note There is a small risk involved with the /F option; the linker may mistakenly translate a byte in a code segment that happens to have the far-call opcode (9A hexadecimal). if a program linked with /F inexplicably fails, they you may want to try linking with this option off. However, object modules produced by Microsoft high- level languages should be safe from this problem, because relatively little intermediate data is stored in code segments.

An application developed for Windows should not use the /PAC linker option switch because it conflicts with the SEGMENTS statements in the application’s module definition DEF file.

Additional reference words: /PACKCODE /NOPACKCODE /NOFARCALLTRANSLATION LinkIss KBCategory: kbtool KBSubcategory: LinkIss

=
================================================================

Copyright Microsoft Corporation 1994.