Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!yetti!geac!daveb From: daveb@geac.UUCP Newsgroups: comp.lang.c Subject: Re: MSC Linking and Libraries Message-ID: <1895@geac.UUCP> Date: Thu, 26-Nov-87 16:11:08 EST Article-I.D.: geac.1895 Posted: Thu Nov 26 16:11:08 1987 Date-Received: Sun, 29-Nov-87 07:38:22 EST References: <3195@rosevax.Rosemount.COM> <1259@laidbak.UUCP> Reply-To: daveb@geac.UUCP (David Collier-Brown) Organization: The little blue rock next to that twinkly star. Lines: 45 Keywords: MSC linker Summary: That's one implementation of it... In article <1259@laidbak.UUCP> daveb@laidbak.UUCP (Dave Burton) writes: >In general: >Linkers can only remove objects called "modules" from libraries. >A module is simply a source file compiled/assembled into an object >file. If the source file contains more than one function, so will >the object. A library archiver then places the object module into >the library, noting only the existance and location of the module >and any external symbols. The linker simply searches the library for >these symbols, extracting the MODULE the symbol is defined within. Well, thats the usual implementation of C. Not all languages/compilers do that, though. The alternative is to put all the functions in as separate linkable items, while arranging for the "top-level statics" to be given a name invisible to the casual user and arranging for the functions which require the statics to reference that name. An example from CP/M (!) is: /* foo.c */ static int harold; foo() { harold = 2; } bar() { printf("%d\n",harold); } maude() { ; } /* end */ Linking either foo or bar will drag in "foo^statics", a block of data two bytes long, containing "harold". Linking maude will nor drag in foo^statics. (I forget what character the linker used for the separator: it wasn't really ^). --dave -- David Collier-Brown. {mnetor|yetti|utgpu}!geac!daveb Geac Computers International Inc., | Computer Science loses its 350 Steelcase Road,Markham, Ontario, | memory (if not its mind) CANADA, L3R 1B3 (416) 475-0525 x3279 | every 6 months.