From owner-freebsd-hackers Tue Nov 20 4: 8:48 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from hoolan.org (db217.csie.ncu.edu.tw [140.115.50.217]) by hub.freebsd.org (Postfix) with ESMTP id 8C53937B405 for ; Tue, 20 Nov 2001 04:06:35 -0800 (PST) Received: from localhost (jeff@localhost [127.0.0.1]) by hoolan.org (8.11.6/8.11.6) with ESMTP id fAKC6N911569 for ; Tue, 20 Nov 2001 20:06:34 +0800 (CST) (envelope-from jeff@hoolan.org) Date: Tue, 20 Nov 2001 20:06:23 +0800 (CST) From: freebsd@hoolan.org X-Sender: jeff@hoolan.org To: freebsd-hackers@freebsd.org Subject: c++ compiler allocates uninitialized global variable in .data section Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message