smart linker

Doug McDonald mcdonald at aries.scs.uiuc.edu
Fri Feb 22 08:11:55 AEST 1991


In article <15279 at smoke.brl.mil> gwyn at smoke.brl.mil (Doug Gwyn) writes:
>In article <1991Feb21.102123.9868 at cs.umn.edu> swie at cs.umn.edu (S. T. Tan) writes:
>>Is there a C compiler bundled with a "smart linker" for DOS?
>>What I meant by a smart linker is the linker which will only link and include 
>>those routines which are referenced in the main program, and all of the 
>>remaining unused routines are ignored so that the size of the excutable file 
>>can be reduced.
>
>While I'm not aware of the characteristics of MS-DOS C offerings,


I am. In general they work just like Unix.

>I feel I should point out that the selective linking must  be done
>on the basis of OBJECT MODULE, not FUNCTION. 


Here "must" is too strong. There is a continuum of gradation between
"source code" and "executable code". the MIPS compilers for instance
have an intermediate form of code that is such that subroutines
in modules can indeed be left out of the final executable. This is
just deferring dead code elimination to a "link" step.


(Note: I not sure that the MIPS system actually DOES this.)

> (An object module
>would be the linkable unit produced by compiling one "translation
>unit" [in C standard parlance].)  Generally in the UNIX world
>linkers do act that way and also do not include in the image any
>object modules from libraries except when they are needed to
>satisfy external references.  With a minor amount of assistance
>from the compiler, it is even possible to exploit this behavior
>to exclude floating-point support from printf() when there has
>been no use of floating-point in the program being linked.

As to this latter floating point stuff, MS-DOS also does this.

Doug McDonald



More information about the Comp.lang.c mailing list