This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Re: How to inform the linker not to produce any data for a .bsssection?
- From: "PRC" <panruochen at gmail dot com>
- To: Daniel Jacobowitz <drow at false dot org>, pkoning <pkoning at equallogic dot com>
- Cc: binutils <binutils at sourceware dot org>
- Date: Tue, 11 Dec 2007 09:19:12 +0800
- Subject: Re: Re: How to inform the linker not to produce any data for a .bsssection?
- References: <200712091050318718404@gmail.com>, <20071209200658.GA26653@caradoc.them.org>
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