Re: will linker leave out unused symbols from binary?

From: David Harmon (source_at_netcom.com)
Date: 09/28/04


Date: Tue, 28 Sep 2004 18:04:53 GMT

On Tue, 28 Sep 2004 16:16:45 +0200 in comp.lang.c++, "Sam Smith"
<sam@smith.com> wrote,
>If I choose to build the executable directly with only relevant source
>files, I know I do not bloat the executable with symbols and functions that
>are never used.

A typical common behavior is that the linker will pull out of the
library any object file that is needed to satisfy a reference, and leave
out any object file that is completely unused, but it cannot split up
any object file and bring in part of it. For best results the library
must be built out of many small object files each containing the
smallest working subset of mutually dependent code and data.

Of course this is outside the scope of the C++ language and you must
read the fine manual of your particular implementation.



Relevant Pages

  • Re: Undefined symbols in 2.6.11-rc5-mm1
    ... the problem is that this is still an internal reference in the same ... > the symbols in that object file are needed to resolve a reference and ... > into an archive/lib, ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Im a stupid blond :( Please help me!!!
    ... > for the linker to figure out if a function is referenced or not. ... table of some sort) indicating that it is an unresolved external reference. ... It's the loader's job to adjust them ... get the entire object file that contains that function linked in. ...
    (comp.lang.cpp)
  • Re: Undefined symbols in 2.6.11-rc5-mm1
    ... the problem is that this is still an internal reference in the same ... the symbols in that object file are needed to resolve a reference and ... which otherwise would be used by the kernel to look up that symbol. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Undefined symbols in 2.6.11-rc5-mm1
    ... >> the symbols in that object file are needed to resolve a reference and ... linked into the kernel image and don't take up space. ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)