linking with glibc library

Ben Elliston bje@redhat.com
Tue May 22 18:12:00 GMT 2001


>>>>> "Tat" == Tat Kee Tan <tktan@EE.Princeton.EDU> writes:

  Tat> I think somebody mentioned this before...Is it true that
  Tat> when we use a function in a glibc library, all the functions
  Tat> in that library will be included in the final executable ?
  Tat> How to tell gcc not to do that ?

That's not correct.

Firstly, if you link to glibc dynamically, then none of the text for
glibc functions will be included in your final executable.

If you link statically and call a function in glibc, the linker will
pull in all symbols from the object file that defines the function you
use.  When C libraries are written, functions are usually kept to one
object file each for this reason.

You might also want look at the -ffunction-sections option to GCC.

Ben



More information about the Binutils mailing list