Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Mar 2011 13:29:53 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Matthew Fleming <mdf356@gmail.com>
Cc:        Roman Divacky <rdivacky@freebsd.org>, freebsd-current@freebsd.org, Dimitry Andric <dim@freebsd.org>
Subject:   Re: [TESTING]: one more boot2 shrinking patch
Message-ID:  <201103101329.54044.jhb@freebsd.org>
In-Reply-To: <AANLkTik-Ps7qt4WAyRnOGtwpxSQKaXqB5u4GMfBivLiJ@mail.gmail.com>
References:  <20110308173909.GA71091@freebsd.org> <20110310163732.GA38320@freebsd.org> <AANLkTik-Ps7qt4WAyRnOGtwpxSQKaXqB5u4GMfBivLiJ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday, March 10, 2011 11:58:30 am Matthew Fleming wrote:
> On Thu, Mar 10, 2011 at 8:37 AM, Roman Divacky <rdivacky@freebsd.org> wrote:
> > On Thu, Mar 10, 2011 at 09:20:58AM -0500, John Baldwin wrote:
> >> On Wednesday, March 09, 2011 6:24:36 pm Dimitry Andric wrote:
> >> > On 2011-03-09 14:23, John Baldwin wrote:
> >> > >> gcc nor clang emits any code to initialize static type foo = 0;
> >> > >> because it's expected that BSS is zeroed, which is not the case
> >> > >> in boot2 so we have to initialize that explicitly
> >> > > It used to be that if you explicitly initialized a variable to 0, it was
> >> > > initialized to 0 in .data, but now gcc and clang recognize it is set to 0 and
> >> > > move it to .bss.  There appears to be no way to turn this feature off,
> >> >
> >> > Yes, there is; both gcc and clang have this option to turn it off:
> >> >
> >> > -fno-zero-initialized-in-bss
> >> >      If the target supports a BSS section, GCC by default puts variables
> >> >      that are initialized to zero into BSS. This can save space in the
> >> >      resulting code.
> >> >
> >> >      This option turns off this behavior because some programs
> >> >      explicitly rely on variables going to the data section. E.g., so
> >> >      that the resulting executable can find the beginning of that
> >> >      section and/or make assumptions based on that.
> >> >
> >> >      The default is -fzero-initialized-in-bss.
> >>
> >> Hah, that is better then.  Thanks! I should have searched about this more
> >> myself. :(  Roman, can you try reverting the kname changes and adding this
> >> to CFLAGS instead for both compilers?
> >
> > when I put -fno-zero-initialized-in-bss clang does not fit by 1.7K and
> > gcc by 0.5K, we dont want this :)
> 
> If there's that many variables explicitly initialized to zero, does
> boot2 then need to explicitly bzero all of bss, not just kname, since
> it's not handled by the loader?  Otherwise it sounds like either
> there's a lot of explicitly initialized variables that didn't need to
> be, or there's a lot of potential for uninitialized variable nonsense
> to happen.

Yes.  It would be good to see which symbols move from .bss to .data with this
change.  Hopefully the compilers aren't putting everything into .data.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103101329.54044.jhb>