Q48204: Linker Can Indiscriminately Bind Different Types

Article: Q48204
Product(s): Microsoft Programming Utilities
Version(s): MS-DOS:1.x,2.x,3.x,4.x,5.01,5.02,5.03,5.05,5.1,5.11,5.13,5.15,5.3,5.31.009,5.5
Operating System(s): 
Keyword(s): kb16bitonly
Last Modified: 30-OCT-1999

-------------------------------------------------------------------------------
The information in this article applies to:

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

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 
Technology        : kbAudDeveloper kbZNotKeyword3 kbLINKSearch kbLINK1xDOSSearch kbLINK2xDOSSearch kbLINK3xDOSSearch kbLINK4xDOSSearch kbLINK503DOS kbLINK510DOS kbLINK511DOS kbLINK513DOS kbLINK515DOS kbLINK530DOS kbLINK53109DOS kbLINK550DOS kbLINK505DOS
Version           : MS-DOS:1.x,2.x,3.x,4.x,5.01,5.02,5.03,5.05,5.1,5.11,5.13,5.15,5.3,5.31.009,5.5

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