> -----Original Message-----
> From: Richard Henderson [mailto:r...@redhat.com]
> Sent: Tuesday, April 19, 2011 1:31 PM
> To: Georg-Johann Lay
> Cc: gcc-patches@gcc.gnu.org; Weddington, Eric; Denis Chertykov; Anatoly
> Sokolov
> Subject: Re: [Patch,AVR]: PR18145: do_copy_data & do_clear_bss only if
> needed
> 
> On 04/18/2011 10:20 AM, Georg-Johann Lay wrote:
> > +avr_asm_named_section (const char *name, unsigned int flags, tree decl)
> > +{
> > +  if (!avr_need_copy_data_p)
> > +    avr_need_copy_data_p = ((0 == strncmp (name, ".data", 5)
> > +                             || 0 == strncmp (name, ".rodata", 7)
> > +                             || 0 == strncmp (name, ".gnu.linkonce.",
> 14)));
> > +
> > +  if (!avr_need_clear_bss_p)
> > +    avr_need_clear_bss_p = (0 == strncmp (name, ".bss", 4));
> 
> Have a look at FLAGS.  I expect that you can reference those to
> categorize the data rather than hard-coding the section names.
> In particular I believe your ".gnu.linkonce" test is wrong.
> 
> It's not clear to me what you're looking for wrt "data".

We're looking for the existence of global initialized data variables.

We have 2 small subroutines in our libgcc, one to set everything in .bss to 
zero, and another to copy the initializations from .text (in flash) to the RAM 
based variables in .data. These subroutines have always been included in the 
startup code whether they were needed or not. The purpose of this patch is to 
check whether these subroutines are actually needed or not (i.e. if anything 
actually exists in .bss, or in .data). If either of these sections are actually 
empty, then we don't want to link in the corresponding subroutine, which helps 
us save some code space on small devices.

AFAICT, I've never seen the avr target generate anything in .rodata and 
.gnu.linkonce sections. I think these might be holdovers from some other target 
code and/or there for some completeness reason, I'm not really sure.

Eric Weddington

Reply via email to