This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
dead code removal
- To: gcc at gcc dot gnu dot org
- Subject: dead code removal
- From: Jim Reekes <reekes at kerbango dot com>
- Date: Mon, 29 Nov 1999 13:53:45 -0800
- Organization: Kerbango
- Reply-To: reekes at kerbango dot com
I have a test program that contains a routine DummyFunc() which is never
reference. Building this single source file in any way I've tried
results in a binary which contains DummyFunc(). Using nm and objdump, as
far as I can determine the GNU tools do not dead-code strip. (which I
find amazing!). I realize this support should be provided by a linker,
and not gcc. I have two questions.
Do the GNU tools provide dead-code stripping?
- or -
How can I find unused/unreferenced symbols so that I can bury the dead
code manually?
I found this related message posted by Jeffrey, but do not know how to
contact him. He eludes to this being supported.
Jim
>From: Jeffrey A Law <law@upchuck.cygnus.com>
>Newsgroups: comp.compilers
>Date: 27 May 1999 23:25:13 -0400
>Organization: Compilers Central
>References: 99-05-091 99-05-105
>Keywords: linker
>> >Actually, CodeWarrior for Win32 (by default) and MS Visual C++ (when
>> >used with the /Gy switch) both perform this procedure you mention --
>> >we put each procedure in its own section, and the respective linkers
>> >dead-strip out unused functions in the final executable.
>>
>> The Watcom C/C++ linker also removes dead code and can remove unused
>> non-virtual and virtual functions by choice.
>
>The GNU tools can do this on ELF platforms. Though the removal of
>unused virtual functions isn't supported on all platforms (yet).