Using a shared library to partly replace an archive library - ld changed behaviour
Graham Hudspith
gwh@allinea.com
Fri Apr 29 17:01:00 GMT 2005
H. J. Lu wrote:
>
>Can you try one thing for me?
>
>1. Build and run your original test on RH9.
>2. Send me your output on RH9.
>3. Copy the binaries to FC3.
>4. Run the same binaries, which are built on RH9, on FC3.
>5. Send me your output on FC3.
>
>
>
H. J. ,
Thanks for your persistence. Here are the results of building and
running my example under RH9:
[opt-testing@fender modified]$ make
gcc -B./ -O -g -c -o main.o main.c
gcc -B./ -O -g -fPIC -c foo.c -o shared.o
gcc -B./ -shared -o libshared1.so shared.o
gcc -B./ -O -g -fPIC -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 -Wl,-rpath,.
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 -Wl,-rpath,.
./main1
Shared library
Real bar
./main2
Real bar
./main3
Shared library
Real bar
As you can, all three examples work correctly. Now, copying the
binaries across to an FC3 system:
[gwh@snowball modified]$ make
./main1
Shared library
Real bar
./main2
Real bar
./main3
Shared library
Real bar
So, the RH9 binaries execute correctly under FC3. Now to BUILD and
run under FC3:
[gwh@snowball modified]$ make
gcc -B./ -O -g -c -o main.o main.c
gcc -B./ -O -g -fPIC -c foo.c -o shared.o
gcc -B./ -shared -o libshared1.so shared.o
gcc -B./ -O -g -fPIC -c bar.c -o bar.o
ar rv libfoo.a bar.o
ar: creating libfoo.a
a - bar.o
gcc -B./ -o main1 main.o libshared1.so libfoo.a -Wl,-rpath,.
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 -Wl,-rpath,.
./main1
Real bar
./main2
Real bar
./main3
Shared library
Real bar
You can see that the run of "main1" has failed.
I've attached the source-code again, just so we know which set we
are talking about.
Regards,
Graham.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: original.tar.gz
Type: application/x-gzip
Size: 762 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20050429/15327d52/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3385 bytes
Desc: S/MIME Cryptographic Signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20050429/15327d52/attachment-0001.bin>
More information about the Binutils
mailing list