Shared libraries

John Coolidge coolidge at casca.cs.uiuc.edu
Tue Aug 14 07:21:58 AEST 1990


liam at cs.qmw.ac.uk (William Roberts) writes:
>I am currently trying to shoehorn a workable A/UX root partition into
>10 Megabytes (well, it keeps me off the streets). During this exercise,
>I have noticed that some binaries are nice and small, whilst others
>are quite a lot larger for not much more functionality.

I can shed some light on this. I've got a version of the SVR3
shared library documentation, which appears to describe a superset
of the A/UX (SVR2) shared library system. There's a section
describing (but not going into detail) the construction of the
shared libc. They mention that, for performance reasons (not
binding in dead data and init code to applications) they split
off "commonly-used" parts of libc and made them shared while
keeping the rest statically linked. If you look at libc with nm,
you'll find that about 195 entries have bizarre names (hft*) ---
these are the shared parts. The other parts with normal names
are normal library entries and will be linked statically.

>Turning to my trusty BSD 4.2 source code, I try compiling chmod.c and
>chgrp.c, only to discover that I can't seem to match the size that
>the distributed /bin/chmod achieves. Furthermore, there are no clear
>examples in the A/UX 2.0 distribution (online manuals only) to say
>exactly HOW to compile and link for shared libraries.

That's an understatement :-). I'd be dead in the water except
for the persence of the SVR3 documentation I'm reading (for those
interested, the 3B1 or the SGI IRIX documentation is very close).
The gcc I've released will link with shared libraries, or you can
build a test program and link with -lc_s and use cc -v to find
out what's being linked in (the important bits are: use crt1 and
crt2 first, crtn later, and shlib.ld LAST!).

>[...] Running "strings /bin/chgrp | wc" shows that there are 3771 bytes
>of printable string (or thereabouts), most of which is the standard
>error strings used by perror: chgrp uses perror, chmod doesn't.

>Can anyone at Apple shed any light on all this? Have I just found a
>way to make the A/UX 2.0 distribution smaller by 20k for most of
>the 729 "executable" things listed in /FILES (a modest saving of 14 Meg!)?

It looks like it, indeed. Given the simplicity of perror it
shouldn't even be hard to write one and built a shared version
of it which incorporates the strings from libc. Perhaps I'll
try it tonight... (Note: this is being written away from my
A/UX machine; I reserve the right to discover that this is a bad
idea :-)).

--John

--------------------------------------------------------------------------
John L. Coolidge     Internet:coolidge at cs.uiuc.edu   UUCP:uiucdcs!coolidge
Of course I don't speak for the U of I (or anyone else except myself)
Copyright 1990 John L. Coolidge. Copying allowed if (and only if) attributed.
You may redistribute this article if and only if your recipients may as well.



More information about the Comp.unix.aux mailing list