This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Fw: Does ld removes uncalled functions from final exe ?
- From: Nick Clifton <nickc at redhat dot com>
- To: Valery Pykhtin <pykhtin at prosoft dot ural dot ru>
- Cc: binutils at sources dot redhat dot com
- Date: Mon, 06 Sep 2004 09:06:18 +0100
- Subject: Re: Fw: Does ld removes uncalled functions from final exe ?
- References: <00f601c493e2$5ae733d0$9926a8c0@prosoft.ural.ru>
Hi Valery,
I wrote simple test program to discover wheter ld removes unreachable code.
The linker does not do this by default. To achieve the affect you want
compile your code with the -ffunction-sections switch specified and then
link with the -gc-sections switch. eg like this:
gcc -ffunction-sections -c test.c testfx.c
gcc -Wl,-gc-sections test.o testfx.o
Cheers
Nick