ranlib and ``ucb''

guy at sun.UUCP guy at sun.UUCP
Fri Jul 11 04:54:04 AEST 1986


> As I understand it, the System V `ar' has a `virtual ranlib' built in
> to it; running `ar' on an object file (one with an appropriate magic
> number) automatically builds or updates the __.SYMDEF archive member.

Yup.  The symbol table archive member's name is a null string, rather than
"__.SYMDEF".  Actually, running "ar" with any command to update the archive,
or with the "s" keyletter, builds, updates, or deletes the table-of-symbols
member; if there were any object files in the archive, it's installed,
otherwise it's not.  The temporary intermediate-file version of the archive
doesn't have the table of symbols, so if it's not installed it is in effect
deleted, so if you have an archive with some object files and some
non-object files, deleting all the object files makes the table of symbols
disappear.

> It seems to me that this is the correct external behaviour: the library
> builder should manage its table of contents itself.

Yes, it's less error-prone, which is presumably why most other OSes do it
this way.  (It's not perfect; if you copy an archive file, you have to do
"ar ts <archive> >/dev/null" to reconstruct the table of symbols.  You
could, of course, write a script to do

	for i in "$@"
	do
		ar ts $i >/dev/null
	done

and call it "ranlib"....  The 4.3BSD "ranlib" has a "touch" option
which merely updates the time on the table-of-symbols member, rather than
rebuilding it, which is useful for the case described above.)

> (I would be just as happy with a /usr/bin/ar shell script that invoked
> ranlib when inserting an object file, although it would probably be slower.)

Actually, the equivalent would be a script which ran "ranlib" if 1) any
command to update the archive were run or 2) the "s" keyletter were
specified.  The only differences here would be that the table of symbols
would always be installed, whether the archive had any object files in it or
not, and would never be deleted.
-- 
	Guy Harris
	{ihnp4, decvax, seismo, decwrl, ...}!sun!guy
	guy at sun.com (or guy at sun.arpa)



More information about the Comp.unix.wizards mailing list