This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Unused functions not being removed
- From: Asm Twiddler <asmtwiddler at gmail dot com>
- To: Asm Twiddler <asmtwiddler at gmail dot com>, binutils at sourceware dot org
- Date: Thu, 1 Aug 2013 15:29:12 -0400
- Subject: Re: Unused functions not being removed
- References: <CAFqBspjcsL0T9YMLbhP0pGAUXwE7YECGrUWr0CjPs3qumAJpyA at mail dot gmail dot com> <20130801031021 dot GJ3294 at bubble dot grove dot modra dot org>
Thanks for the response.
This is my first time really posting on the mailing lists.
So, should I submit this as a bug or is it enough that it's posted here?
Thanks.
On Wed, Jul 31, 2013 at 11:10 PM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Jul 31, 2013 at 10:33:54PM -0400, Asm Twiddler wrote:
>> Hello all,
>>
>> I have recently noticed that some of the unused functions in my code
>> aren't being removed.
>> It appears that the problem occurs due to ld, but only when building
>> for the avr.
>>
>> My code is compiled using -fdata-sections and -ffunction-sections to
>> create object files.
>> Then, per each source directory, different object files are combined
>> into one object via "ld -r".
>> Finally, those objects are compiled together using gcc --gc-sections.
>> This should remove any unused functions, as it does under x86, but fails on avr.
>> After running objdump on the various objects, it appears that gcc is
>> correctly creating the sections, but "ld -r" is removing the separate
>> sections.
>>
>> Is this supposed to happen and is there a way to disable this?
>
> ld -r is supposed to merge sections of the same name. If ld -r is
> doing more than that, eg. putting .text.foo and .text.bar into .text,
> then that would be a ld -r bug on avr. From the look of
> ld/scripttempl/avr.sc I'd guess exactly that is happening.
>
> *(.text.*) there ought to be ${RELOCATING+*(.text.*)} and a whole lot
> of other lines similarly.
>
> --
> Alan Modra
> Australia Development Lab, IBM