Re: How do linkers work? (John R. Strohm)
27 Oct 1999 14:10:25 -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: (John R. Strohm)
Newsgroups: comp.compilers
Date: 27 Oct 1999 14:10:25 -0400
Organization: Internet America
References: 99-10-097 99-10-107
Keywords: linker, comment

( said...
>Dave Wilson ( wrote:
>: I have a slight problem.
>: [ program links library routine Bill() not called from the main program
>: that calls Fred() ]
>Static libraries contain object files. With `nm' you can see what
>object files are there, and what functions they contain. The linker
>always links complete object files, so that if Fred() and Bill() are
>in the same object file, and you link Fred(), you also link Bill().
>Object files in libraries that contain no functions that are used are
>not linked.

That may be how your particular linker works.

In the old days, before 32 Mb of RAM was considered "small", linkers
were required to be a little bit smarter.

In particular, the linkers for the CDC 6600 were VERY careful only to
link routines out of libraries that were actually referenced by user
code or by previously-linked routines. With only 131072 60-bit words
of core to play wiht, of which a fair chunk was reserved for the
resident portion of the operating system, it simply was not possible
to link everyting including the kitchen sink.

The 6600 linkers did require the user to specify multiple libraries in
a correct order, so that a single pass would find everything. Since
the usual case was just to link against the FORTRAN runtime library,
this wasn't usually a problem.
[The regular Unix linkers do pull one routine at a time from a library.
As I think I've now said about 15 times, the problem here occurs when
using shared libraries, because each shared library acts like a single
module. -John]

Post a followup to this message

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