On Tue, Oct 25, 2011 at 3:57 PM, Jeremy Huntwork <jhuntw...@lightcubesolutions.com> wrote: > There appears to be a somewhat bogus statement in section 6.63 > "Stripping Again". It says there: > "If disk space is very tight, the --strip-all option can be used on > the binaries in /{,usr/}{bin,sbin} to gain several more megabytes. Do > not use this option on libraries—they will be destroyed." > The statement that libs will be destroyed by --strip-all may be > correct for chapter 5 libs due to the adjustments we've made (and will > yet make) in chapter 6, the nature of the varying environments. > However, by the end of chapter 6 I don't believe that statement is > true any more.
Looks like you are indeed right about shared libraries. strip removes the regular symbol table, but doesn't touch the dynamic symbol table. Here's an example. # Create some separate directories mkdir full stripped # Make a simple shared and static library cat > dragon.c << "EOF" #include <stdio.h> void dragons(void) { printf("Here be dragons!\n"); } EOF gcc -c -o dragon.o -fPIC dragon.c gcc -o full/libdragon.so -shared dragon.o ar r full/libdragon.a dragon.o ranlib full/libdragon.a # Make stripped copies of the libraries cp full/* stripped/ strip --strip-all stripped/* # Look at the symbol tables of the shared libraries # Notice that the .symtab section of the stripped library # is gone, but the .dynsym sections are identical readelf -s */libdragon.so # Look at the symbol tables of the static libraries # Notice that the stripped library has no symbols left readelf -s */libdragon.a # Make a test app cat > test.c << "EOF" extern void dragons(void); int main(void) { dragons(); return 0; } EOF # Build and run against stripped shared library # Notice that it runs fine gcc -o test test.c -Lstripped -ldragon LD_LIBRARY_PATH=stripped ./test # Now try again with the stripped static library # Notice that it fails to build gcc -o test test.c stripped/libdragon.a So, it seems that --strip-all will only destroy your static libraries. I couldn't find any way to strip the .dynsym section out of the generated binaries. Then later I found this: http://www.technovelty.org/linux/strip.html Interesting stuff. -- Dan -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page