From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31692 invoked by alias); 11 Dec 2007 01:19:45 -0000 Received: (qmail 31679 invoked by uid 22791); 11 Dec 2007 01:19:43 -0000 X-Spam-Check-By: sourceware.org Received: from rv-out-0910.google.com (HELO rv-out-0910.google.com) (209.85.198.185) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 11 Dec 2007 01:19:37 +0000 Received: by rv-out-0910.google.com with SMTP id l15so1758981rvb for ; Mon, 10 Dec 2007 17:19:35 -0800 (PST) Received: by 10.140.82.38 with SMTP id f38mr1974269rvb.1197335975465; Mon, 10 Dec 2007 17:19:35 -0800 (PST) Received: from ghost ( [221.218.184.181]) by mx.google.com with ESMTPS id l27sm6998737rvb.2007.12.10.17.19.30 (version=SSLv3 cipher=OTHER); Mon, 10 Dec 2007 17:19:33 -0800 (PST) Date: Tue, 11 Dec 2007 01:19:00 -0000 From: "PRC" To: Daniel Jacobowitz , pkoning Cc: binutils References: <200712091050318718404@gmail.com>, <20071209200658.GA26653@caradoc.them.org> Subject: Re: Re: How to inform the linker not to produce any data for a .bsssection? Message-ID: <200712110919091773244@gmail.com> X-mailer: Foxmail 6, 9, 201, 16 [cn] Mime-Version: 1.0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: 7bit Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00055.txt.bz2 There is a global static array in my code: static char cmd_buffer[1024*64] __attribute__(( section(".mydata") )); And inform the linker to put it in section ".bss": .bss : { *(.bss) *(COMMON) *(.mydata) } mips-elf-objdump -h a.out ------------------------------------------------------------------- 3 .bss 00010620 81413898 81413898 00003898 2**3 ALLOC 4 .reginfo 00000018 00000000 00000000 00013eb8 2**2 CONTENTS, READONLY, LINK_ONCE_SAME_SIZE ------------------------------------------------------------------ The difference between sections ".bss" and ".reginfo" is almost 64K, which is just the size of the buffer `cmd_buffer`. And I check the output file, and find there are lots of zero starting from the offset 0x3898. It seems the linker puts 64K zeros in the section ".bss". On Sun, Dec 09, 2007 at 10:50:50AM +0800, PRC wrote: > 2 .bss 00000620 811eeb00 811eeb00 00002b00 2**3 > ALLOC > The linker create a real '.bss' section in the output ELF file and > store some data inside the section, which greatly increase the size > of the ELF file. No, it didn't. It takes up no space in the file because it does not have the CONTENTS flag. -- Daniel Jacobowitz CodeSourcery