This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: [Q] linking only some functions in an object file
- To: jw c <info2choijo at yahoo dot com>
- Subject: Re: [Q] linking only some functions in an object file
- From: Nick Clifton <nickc at cambridge dot redhat dot com>
- Date: 19 Apr 2001 08:47:24 +0100
- Cc: binutils at sources dot redhat dot com
- References: <20010419043545.29549.qmail@web1805.mail.yahoo.com>
Hi jw,
> For example, when I link test.o test2.o and make
> test.elf, all of functions in test.o test2.o gets in
> test.elf.
>
> But I don't want not-used-functions to get in
> test.elf. How can I do this?
Another possible solution, if you are using gcc, is to use the command
line switch -ffunction-sections. This places each function compiled by
gcc into its own, individually named section. Then when you link
together the object files, add the linker command line switch
--gc-sections. This will cause the linker to throw away all sections
that it finds are not needed, which I believe is what you want.
Please note the support for -ffunction-sections is not present in all
gcc targets, so you may not be able to use this method.
Cheers
Nick