Microsoft KB Archive/48204

From BetaArchive Wiki
< Microsoft KB Archive
Revision as of 16:56, 18 July 2020 by 3155ffGd (talk | contribs) (importing KB archive)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Base


Linker Can Indiscriminately Bind Different Types

Article ID: 48204

Article Last Modified on 9/30/2003



APPLIES TO

  • Microsoft LINK for MS-DOS 1.x
  • Microsoft LINK for MS-DOS 2.x
  • Microsoft LINK for MS-DOS 3.x
  • Microsoft LINK for MS-DOS 4.x
  • Microsoft LINK for MS-DOS 5.03
  • Microsoft LINK for MS-DOS 5.05
  • Microsoft LINK for MS-DOS 5.1
  • Microsoft LINK for MS-DOS 5.11
  • Microsoft LINK for MS-DOS 5.13
  • Microsoft LINK for MS-DOS 5.15
  • Microsoft LINK for MS-DOS 5.3
  • Microsoft LINK for MS-DOS 5.31.009
  • Microsoft LINK for MS-DOS 5.5



This article was previously published under Q48204

The object module format used by the Microsoft languages contains a record type that is used to bind symbol definitions to symbol references in other modules. This record is known as a "fixup." As defined by Intel, the fixup record type contains no information as to the type of data that is to be fixed up. Under certain circumstances, this can cause unexpected and undesired binding at link time. The code below demonstrates such an instance:

    /*----- FILE1.C -----*/ 

    void bar( void );

    void main( void )
    {
        bar();
    }


    /*----- FILE2.C -----*/ 

    int bar;
        

These files both compile without error. When compiled for a model with a single code segment, linker error L2003 is produced saying that an intersegment self-relative fixup was attempted. If a multiple code segment model is used, no link errors are produced. Although a clean link can be obtained, the resultant EXE does not perform as expected due to the fact that the function reference of bar in FILE1.C has been bound to the integer definition of bar in FILE2.C.

The linker has no way of determining the types of the reference to, and definition of, bar. This is a limitation of the object file format. If an include file was used to prototype bar and was then included in both files, the compiler could have detected the redefinition of bar.

This information applies to all versions of LINK.


Additional query words: kbinf 3.60 3.61 3.65 4.06 4.07

Keywords: kb16bitonly KB48204