Subject: Re: Shared libraries
To: Todd Vierling <email@example.com>
From: Ian Dall <firstname.lastname@example.org>
Date: 06/28/1999 22:23:35
Todd Vierling <email@example.com> writes:
> On Sun, 27 Jun 1999, Ian Dall wrote:
> : If I do
> : gcc -shared -o libfoo.so.1.0 a.o b.o c.o
> This is presuming NetBSD 1.4 or later, of course - on NetBSD 1.3.x on a.out
> systems, "gcc -shared" was horribly broken and you really needed "ld
> -Bshareable". NetBSD 1.3.x on ELF had other restrictions (see below), but
> worked fine.
Does this depend on whether gas.new and ld.new are in use?
> If you do happen to supply the dependencies on either a.out *or* ELF, the
> runtime linker (ld.so or ld.elf_so) will automatically load the dependent
> library at program runtime.
So a reference to the dependent library is salted away somewhere.
I noticed that
gcc -shared -o libfoo.so.1.0 a.o b.o c.o
gcc -shared -nostdlib -o libfoo2.so.1.0 d.o -lfoo
results in an error because it can't find libc. All is OK if you do
-nostdlib -L/usr/lib. It seems odd (and undocumented) that -nostdlib
not only doesn't link the standard libraries, but also changes the
library search path.
> However, the default is just to set a dependency in the library upon libc
> (*if* you are using cc -shared on 1.4 or specifying -lc).
Yes this is a 1.4 toolchain, but some of the libraries, notably the X
libraries, are older. Does that matter?
> This smells like you may, in fact, be on NetBSD 1.3.x on a.out. See above
> comment about gcc -shared vs. ld -Bshareable. In any case, if you're on
> 1.4, you should not use -nostdlib.
OK, so that seems like "the right thing" to do. Unfortunately I get ld
errors (in the mozilla build I mentioned) if I do that. I had assumed
it was because something (libgcc.a) wasn't compiled with -fpic...
> : specifically of libgcc.a. If a, b or c call a function in libgcc.a, is
> : it extracted from libgcc.a and linked? If so that is almost certainly
> : wrong since libgcc.s doesn't appear to be compiled with -fpic.
> libgcc _is_ compiled -fpic.
Well, I can assure you my libgcc isn't, I still have the log file on line
and I have checked.
It looks like the question I have to solve is why isn't my libgcc
being compiled with -fpic? I am working off a gnu.tar.gz I fetched on
June 3. I see nothing in gnu/lib/libgcc/Makefile which looks like it
is intended to set -fpic on any port. Where should I look?