How do linkers work?

"Dave Wilson" <>
21 Oct 1999 00:47:29 -0400

          From comp.compilers

Related articles
How do linkers work? (Dave Wilson) (1999-10-21)
Re: How do linkers work? (1999-10-21)
Re: How do linkers work? (Alan Donovan) (1999-10-21)
Re: How do linkers work? (1999-10-21)
Re: How do linkers work? (1999-10-21)
Re: How do linkers work? (1999-10-27)
| List of all articles for this month |

From: "Dave Wilson" <>
Newsgroups: comp.unix.programmer,comp.compilers
Date: 21 Oct 1999 00:47:29 -0400
Organization: TTL
Keywords: linker, question, comment


I have a slight problem.

Consider a static library containing several functions. Some of the
functions in the library (e.g. Fred()) are contained entirely within
the library, whereas others (e.g. Bill()) call functions outside the

Now it makes sense that programs that use the library and call Bill() need
to defined the functions that Bill() calls before a successful link.

However, much to my dismay, programs that only use Fred() from the
library also need to define the functions that Bill() needs __even
though this code is never executed!__.

Forgive me if I'm displaying a certain ignorance about current linker
technology, but I thought linkers could figure out certain things like
which functions will never get called and leave them out.

All comments welcome.

David Wilson, TTL.
[With shared libraries, the linker does indeed tend to drag in the whole
library even when you only need one routine from it. Your moderator
shamelessly suggests you consult "Linkers and Loaders", just published
by Morgan-Kauffman. -John]

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.