On Sat, Dec 04, 2010 at 11:36:25AM +0100, Roman Divacky wrote: > On Fri, Dec 03, 2010 at 06:17:16PM -0500, Jung-uk Kim wrote: > > On Friday 03 December 2010 06:02 pm, Jung-uk Kim wrote: > > > On Friday 03 December 2010 05:43 pm, Jung-uk Kim wrote: > > > > On Friday 03 December 2010 05:08 pm, John Baldwin wrote: > > > > > On Friday, December 03, 2010 4:54:10 pm Jung-uk Kim wrote: > > > > > > Author: jkim > > > > > > Date: Fri Dec 3 21:54:10 2010 > > > > > > New Revision: 216161 > > > > > > URL: http://svn.freebsd.org/changeset/base/216161 > > > > > > > > > > > > Log: > > > > > > Explicitly initialize TSC frequency. To calibrate TSC > > > > > > frequency, we use DELAY(9) and it may use TSC in turn if TSC > > > > > > frequency is non-zero. > > > > > > > > > > We zero the BSS, so these were already zero. This just makes > > > > > the actual kernel file on disk larger by wasting space in .data > > > > > instead of .bss. > > > > > > > > Please note that I didn't touch other variables, e.g., > > > > tsc_is_broken, because I knew that. However, I just wanted to do > > > > that *explicitly*. Anyway, it is reverted now and SVN will > > > > remember what I wanted to do. ;-) > > > > > > > > BTW, if my memory serves, GCC (and all modern C compilers) put(s) > > > > zero-initialized variables back in .bss. > > > > > > I just tried it. GCC generates identical binaries as I thought. > > > However, Clang doesn't do the optimization. :-/ > > > > Strangely, Clang increases .bss when a global variable is explicitly > > initialized to zero. > > > > - 2 .bss 00000004 0000000000000000 0000000000000000 00000540 2**2 > > + 2 .bss 00000014 0000000000000000 0000000000000000 00000540 2**3 > > in my naive test gcc produces: > > .globl foo > .section .bss > .align 4 > .type foo, @object > .size foo, 4 > foo: > .zero 4 > > > and clang produces: > > .type foo,@object # @foo > .bss > .globl foo > .align 4 > foo: > .long 0 # 0x0 > .size foo, 4 > > ie. both put them into BSS I have no idea how and where your gcc is configured, in particular, I find the non-documenting directive .zero somewhat puzzling.
Behaviour of clang looks like a plain bug, since initialized objects must be put into the .data section, not into .bss. Both gcc 4.2.1/FreeBSD and plain 4.5.1 produce .comm foo,4,4 when compiling the file consisting of long foo; line. For amd64, substitute 4 by 8.
pgpGiDXShPwwb.pgp
Description: PGP signature