I found that c++ compiler (4.4-RELEASE) allocates uninitialized global
variable in the data section instead of the bss section. Here is my
code sample (b.cpp):

char aa[1024*1024*10];

void f(void)
{
}

after c++ -c b.cpp I get a nearly 10MB object file, whereas on linux
(RedHat 7.2, gcc-2.96-98) it produces a file less than 1kB. So I
assemble it to find the diffenece.

on FreeBSD:

.globl aa
.data
        .p2align 5
        .type    aa,@object
        .size    aa,10485760
aa:
        .zero   10485760

but on Linux:

.globl aa
.bss
        .align 32
        .type    aa,@object
        .size    aa,10485760
aa:
        .zero   10485760

In consequence, that's why I get a huge object file with FreeBSD c++.
Is this behavior of c++ correct? I suppose uninitialized data should
goes to .bss section according to elf(5).


Regards,
Jeffrey Tang



To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to