Subject: Re: weird link required, please help?
To: None <current-users@NetBSD.ORG>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: current-users
Date: 05/01/1997 22:55:44
> [not sure if this is absolutely the most correct forum, but people
> around here seem to know lots of stuff :), so...]

Well, if this is on NetBSD, it's probably reasonable. :-)

> i've got two libraries (both called libfoo.a) that implement the same
> protocol, but versions 1 and version 2 of said protocol.  and, of
> course, to provide the absolute ease of porting, they both have
> exactly the same api (eg, functions calls and global variables).

> [want a single program to use both; can change symbol names...?]

> is there any way i can use ld to link libfoo.a with foo1.o into a new
> foo1.o with all symbols from libfoo.a stripped, but with symbols from
> foo1.o intact?

Yes.

I have a program that will take a .o file and frob the N_EXT bits in
the symbol table, thereby (for example) rendering certain symbols,
formerly globally visible, hidden.  Then you can

% ld -x -r foo1.o libfoo.a -o foo1a.o
% localsym -c foo1a.o _visible_symbol_1 _visible_symbol_2 ...
% ld -x -r foo1a.o foo1b.o

Then foo1b.o has only the listed symbols visible; everything else was
made local by localsym, then stripped by ld -x -r.

localsym works only for a.out files, at present; anyone who cares to is
invited to make it work for elf.  Since I don't currently run any ports
that use elf, I have neither incentive nor opportunity to do it myself.

Anyone who would like a copy of localsym is invited to contact me
directly; it's available only by mail from me at the moment.

Of course, this may not solve your problem; it may not be possible for
both versions of the library to coexist in the same process because
they clash over some shared resource, such as the current directory, or
the open file table.  I assume you've considered such dangers.

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B