This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch,AVR]: PR18145: do_copy_data & do_clear_bss only if needed


Weddington, Eric schrieb:

-----Original Message-----
From: Richard Henderson [mailto:rth@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.

When I wrote this patch I looked at the default linker script to see what goes into .data resp .bss; the hard-coded section maned reflect that. For the linkonce stuff I found no explanation (grepping the web yields bunch of questions from people having trouble with it) and in the gcc wiki you find nothing (except you have already a link to what you seek).


The .gnu.linkonce is an overestimation, .gnu.linkonce.d. is perhaps better, but exceptions are not supported on avr, anyway. So an overestimation won't hurt.

Then I wonder where .noinit, .progmem.data, .progmem.gcc_sw_table
would go?

Moreover, with checking section names it might be easier for users that want some private sections treated as cleared by __do_clear_bss or initialized by __do_copy_data.

AFAIK the section attribute does not allow to set section flags?

Eric, you don't see .rodata because of avr.c:avr_asm_init_sections
 readonly_data_section = data_section;
To see .rodata give -fdata-sections for const not in progmem.

The only thing I am a bit uncomfortable with is that there is no command line option to unconditionally reference the __do's.

Johann


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