This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Using a shared library to partly replace an archive library - ld changed behaviour
- From: Daniel Jacobowitz <drow at false dot org>
- To: "H. J. Lu" <hjl at lucon dot org>
- Cc: Graham Hudspith <gwh at allinea dot com>, binutils at sourceware dot org,GNU C Library <libc-alpha at sources dot redhat dot com>
- Date: Sun, 1 May 2005 16:29:49 -0400
- Subject: Re: Using a shared library to partly replace an archive library - ld changed behaviour
- References: <426E4FC1.1000303@allinea.com> <20050426155508.GA22024@lucon.org> <426FBD90.5020302@allinea.com> <20050427172536.GA11878@lucon.org> <4271F5A6.5060309@allinea.com> <20050429144423.GA18650@lucon.org> <427254AB.1030207@allinea.com> <20050501170557.GA13980@lucon.org>
On Sun, May 01, 2005 at 10:05:57AM -0700, H. J. Lu wrote:
> Could someone please run this test on Solaris and report the result
> to me? I'd like to know what Solaris does before I make the change. I
> had the impression that on Solaris, a weak definition in relocatable
> file will override the strong one in DSO.
On Solaris, I needed two changes: use -R instead of -Wl,-rpath, and
explicitly define a new macro when using -fPIC, since my GCC doesn't
appear to define __PIC__.
With those changes the result is:
gcc -B./ -O -g -c -o main.o main.c
gcc -B./ -O -g -fPIC -DPIC -c foo.c -o shared.o
gcc -B./ -shared -o libshared1.so shared.o
gcc -B./ -O -g -fPIC -DPIC -c bar.c -o bar.o
ar rv libfoo.a bar.o
a - bar.o
gcc -B./ -o main1 main.o libshared1.so libfoo.a -R .
gcc -B./ -o main2 main.o libfoo.a
gcc -B./ -shared -o libshared3.so shared.o libfoo.a
gcc -B./ -o main3 main.o libshared3.so libfoo.a -R .
./main1
Real bar
./main2
Real bar
./main3
Shared library
Real bar
So it appears that whatever version of binutils FC3 uses is behaving
identically to Sun's linker.
--
Daniel Jacobowitz
CodeSourcery, LLC