Shared libraries
William Roberts
liam at cs.qmw.ac.uk
Sat Aug 11 05:28:53 AEST 1990
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.
For example:
A/UX 2.0 SunOS 3.5
/bin/chmod 3604 bytes 19292 bytes (+15688)
/bin/chgrp 32812 bytes 46620 bytes (+13808)
The A/UX 2.0 version is using the shared libc, but so is the chgrp
and I don't understand why it is so much bigger.
When I do a "what" on these files, I get
/bin/chmod:
Copyright (c) 1984-85 AT&T-IS, 1985-87 UniSoft Corporation, All Rights
Reserved. {Apple version 1.3 89/10/10 08:10:18}
compatmode.c 1.2
/bin/chgrp:
Copyright (c) 1984-85 AT&T-IS, 1985-87 UniSoft Corporation, All Rights
Reserved. {Apple version 1.4 90/03/16 13:34:16}
compatmode.c 1.2
get_myaddress.c 1.1 86/09/24 Copyr 1984 Sun Micro
The curious thing is that "get_myaddress.c" is part of libc.a, and this
is supposed to be shared.... isn't it?
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.
Looking at the files with "size", I get
Size of /bin/chgrp: 83988
Section Size Physical Address Virtual Address
.text 26596 328 328
.data 5824 4196652 4196652
.bss 16160 4202476 4202476
.lbt1206 26156 1206910976 1206910976
.lbd1207 9108 1207697408 1207697408
.lbb1207 80 1207706516 1207706516
.lib 64 0 0
Size of /bin/chmod: 38972
Section Size Physical Address Virtual Address
.text 2036 328 328
.data 1176 4196668 4196668
.bss 352 4197844 4197844
.lbt1206 26156 1206910976 1206910976
.lbd1207 9108 1207697408 1207697408
.lbb1207 80 1207706516 1207706516
.lib 64 0 0
So chgrp is bigger by 24000 bytes of text and 4700 bytes of data.
The sizes of the chmod.o and chgrp.o files are
chmod.o text=1284 data=156
chgrp.o text= 852 data=188
so all that extra is coming from unshared text & data extracted from
libc. 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!)?
PS: gcc makes all string constants part of the text segment (and hence
non-writeable) by default. The same effect could be achieved with
ld (I think) and would be valuable if applied to errlst.c in the
C library - this just defines the standard error strings and would
put that 2492 bytes of data into somewhere that is truly shared rather
that "copy-on-write" shared.
This treatment of string constants would be useful in lots of
places - just type "strings" on any executable over 40K...
--
William Roberts ARPA: liam at cs.qmw.ac.uk
Queen Mary & Westfield College UUCP: liam at qmw-cs.UUCP
Mile End Road AppleLink: UK0087
LONDON, E1 4NS, UK Tel: 071-975 5250 (Fax: 081-980 6533)
More information about the Comp.unix.aux
mailing list