Is it safe to use "-shared-libgcc" when building a shared library with gcc ?

duncan.loveday@bt.com duncan.loveday@bt.com
Sun May 29 15:09:00 GMT 2011


Hi,

gcc allows me to create a shared library and still statically link libgcc but is that a safe thing to do ?

Often, statically linking code into a shared library is unsafe because the code in the static library is not position independent. Does the static version of libgcc contain position independent code ?

My command line is below for reference. Ignore the fact that the output library is also supplied as a -l to the linker, that is a quirk of the makefiles used.

     gcc -static-libgcc -shared -fPIC -Wl,+h -Wl,libdb-4.5.sl -Wl,+b -Wl,/usr/local/BerkeleyDB.4.5/lib -o .libs/libdb-4.5.sl <list of object files> -lpthread -lc


Thanks,

Duncan.



More information about the Gcc-help mailing list