Why are "Internal Linkage" and "No Linkage" Needed?

ID Number: Q66650

3.x 4.x 5.x 6.x | 5.x 6.x

MS-DOS | OS/2

Question:

I have just finished reading the article "C Scope and Linkage: The

Keys to Understanding Identifier Accesibility" in the November 1988

issue of "Microsoft Systems Journal" and I am not clear on the use of

"Internal" and "No Linkage" types to the linker. It would seem that

variables that are not visible from outside the module would be

resolved at compile time. Because there is no need for the linker to

resolve the references, why would an object record need to be created?

Response:

"Internal Linkage" details the functions/labels in the code that the

compiler will fix up, as best it can, at compile time. However,

because the linker will coalesce the various segment pieces together

(that is, all the _DATA items will be in _DATA, all the _TEXT

functions will go to _TEXT), the linker still has to fix up the final

addresses in the code. Therefore, this information is "Internal" to

the function.

"No Linkage" information is usually data that the linker really has no

use for while creating a final .EXE (for example, items such as

typedefs, structure names, parameters to functions, function local

variables, etc.). These will all be resolved by the compiler (in the

case of the parameters and local variables, which are SS based), or

are only of use to post link fix-up code (that is, debuggers and/or

profilers, etc.). Because this information may be required after the

link stage is completed and the compiler does generate it, it is given

"No Linkage" status and passed through as is.