This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Using a shared library to partly replace an archive library - ld changed behaviour


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]