This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [Q] linking only some functions in an object file


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]