ld and .a file question

Lal learner.kernel@gmail.com
Sat May 29 07:51:00 GMT 2010


Why ld does not extract symbols from archived file in below example?

-bash-3.00$
-bash-3.00$ gcc -c test.c
-bash-3.00$ nm test.o
00000018 T fun1
00000000 T func2
0000002a T main
         U printf
-bash-3.00$ ld -r test.o -o test1.o
-bash-3.00$ nm test1.o
00000018 T fun1
00000000 T func2
0000002a T main
         U printf
-bash-3.00$
-bash-3.00$
-bash-3.00$ ar rvf lib.a test.o
r - test.o
-bash-3.00$ nm lib.a

test.o:
00000018 T fun1
00000000 T func2
0000002a T main
         U printf
-bash-3.00$
-bash-3.00$ ld -r lib.a -o test1.o
-bash-3.00$ nm test1.o
-bash-3.00$

I expected test1.o (in 2nd iteration) to have the symbols, but it does not!

Regards
Lal



More information about the Binutils mailing list