lkml.org 
[lkml]   [2008]   [Feb]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/2] x86 : relocate uninitialized variable in init DATA section into init BSS section
From
Date
On Thu, 2008-02-21 at 10:53 +0100, Ingo Molnar wrote:
> * Huang, Ying <ying.huang@intel.com> wrote:
>
> > > > -int __initdata early_ioremap_debug;
> > > > +int __initbss early_ioremap_debug;
> > >
> > > will we get some sort of build error if we accidentally do:
> > >
> > > int __initbss early_ioremap_debug = 1;
> > >
> > > ?
> >
> > I tested it just now, and there is no build error.
>
> well, that's bad. We'd silently ignore the " = 1" and boot up with that
> value at 0, right? At minimum we need some really prominent build-time
> _errors_ (i.e. aborted builds) if this ever happens. But ideally,
> shouldnt this whole thing be done at link time? Couldnt the linker sort
> the variables that are zero initialized into the right section, and move
> this constant maintenance pressure off the programmer's shoulder?

I think another method is to add a new attribute into GCC to prepend or
append something to section name instead of just to replace it, like the
example as follow:

#define __initdata __attribute__((section_append(".init")))

int __initdata early_ioremap_debug_data = 1;
int __initdata early_ioremap_debug_bss;

The GCC can deduce the section (.data or .bss) of global variable based
on whether it is initialized. That is, without attribute,
early_ioremap_debug_data will be in ".data", early_ioremap_debug_bss
will be in ".bss". And with section_append attribute,
early_ioremap_debug_data will be in ".data.init" and
early_ioremap_debug_bss will be in ".bss.init".

Best Regards,
Huang Ying



\
 
 \ /
  Last update: 2008-02-22 03:39    [W:0.046 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site