Description of problem: First, we create an archieve file lib.a by including file1.o. # ar -cr lib.a file1.o Second, we get lib.a's block size. # ls -s lib.a 8 lib.a # nm -s lib.a Archive index: main in file1.o file1.o: 0000000000000000 r .LC0 0000000000000000 T main U puts Then, we strip its symbols. # strip lib.a # ls -s lib.a 8 lib.a # nm -s lib.a file1.o: nm: file1.o: no symbols Next, use "ar -s" or ranlib to generate symbol index. # ar -s lib.a # ls -s lib.a 8 lib.a # nm -s lib.a file1.o: nm: file1.o: no symbols Version-Release number of selected component (if applicable): binutils-2.18.50.0.9-8.fc10.i386 How reproducible: always Steps to Reproduce: As the above. Actual results: No symbol index generated. Expected results: Symbol index generated. Additional info:
Hi Cai, This is the correct behaviour. Once you have stripped all of the symbols out of the files in the archive (using the "strip lib.a" command) it is no longer possible to regenerate the symbol index. Basically there are no symbols left in the archive, so it is not possible to create an index based on them. If you change the strip command to only remove unneeded symbols then you will be able to create a symbol index. ie: # ar cr lib.a file1.o # strip --strip-unneeded lib.a # ar s lib.a # nm -s lib.a Archive index: main in file1.o file1.o: 0000000000000000 T main U puts Cheers Nick
Thanks Nick! I'll fix the broken test case instead.
Hi Nick, it is not obvious to me "ar -s" makes any different. Please see the following example, $ ar cr lib.a file1.o $ ls -l lib.a -rw-rw-r-- 1 caiqian caiqian 1018 2009-04-02 10:42 lib.a $ nm -s lib.a Archive index: main in file1.o file1.o: 00000000 T main U puts $ strip --strip-unneeded lib.a $ ls -l lib.a -rw-rw-r-- 1 caiqian caiqian 994 2009-04-02 10:42 lib.a $ nm -s lib.a Archive index: main in file1.o file1.o: 00000000 T main U puts $ ar -s lib.a $ ls -l lib.a -rw-rw-r-- 1 caiqian caiqian 994 2009-04-02 10:43 lib.a $ nm -s lib.a Archive index: main in file1.o file1.o: 00000000 T main U puts As you can see from the above, the file size and "nm -s" output did not change at all after "ar -s".
Hi Cai, > it is not obvious to me "ar -s" makes any different It doesn't. :-) It does make a difference on some versions of the ar program, notably those on some Unix and Solaris systems. These versions of ar do not automatically added a symbol index when the archive is created. But the binutils ar automatically adds a symbol index when an archive is created. So the -s option is supported mainly for backwards compatibility with these other versions of ar. Cheers Nick
Thanks a lot, Nick! Those test cases were written a few years back, and I happened to deal with them recently, so I guess they were using the different version of "ar" other than bintuils.