[net.lang.c] Archives

cottrell@nbs-vms.arpa (COTTRELL, JAMES) (01/09/86)

/*
> Is there any way to change the name of a routine in an archive file?

Yeah. Recompile and reachive with a different name. Archives were
not meant to be diddled with. You're either On the Bus or Off the Bus.
 
> My problem is that I have an archive file of routines that call
> the subroutine 'foobarsub(3)'.  Unfortunately, the name has been 
> truncated to eight characters to 'foobarsu' in the archive.
> I only have the object form of the archive, and can't figure out
> how to get the name to refer to the proper subroutine.

So what happens when you try to call `foobarsub'? Perhaps the
loader (or compiler) will truncate to the same length. If not,
try using `foobarsu'. A #define may help make global changes.
 
> Am I missing something simple?  (Probably)

Foobarsu? The new Japanese car for programmers :-) ?!?

	jim		cottrell@nbs
*/
------

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (01/09/86)

The fellow with the "truncated" archive name probably has the
following trouble.

Note first that the linker does NOT use archive member (file)
names to resolve extern references; it uses global entry points.
In older UNIXes, these were found by sequentially scanning all
object members of the archive; in newer versions, the archive
contains a member that is a index of entry points.

For the reported problem, the fellow's current compiler must
support long names (FLEXNAMES, or at least longer-than-before
names), and the member of the archive must date back to pre-
long-names times, when all extern names were truncated to fit
the limited space available in the object module format (by
the assembler, not by the archiver).

Because there is no way for the newer SGS to know that an older
entry point name resulted from the truncation of something
longer, existing names are taken as exactly what they contain.
Long names compiled by the newer SGS will have their full names.
These will not match the older truncated forms.

You can work around this, assuming you can't just recompile the
archive member from its source, by replacing the long names in
you current source by their short versions.  An easy way to do
this is:
	#define	nametoolong nametool
(or whatever) at the beginning of the source file.
AT&T SVR2 cpp is supposed to have a "truncate" option, -T, to
do this for you automatically.