This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: How to expand the `bss`section and fill it zeros when 'objcopy'ing?
- From: Nick Clifton <nickc at redhat dot com>
- To: PRC <panruochen at gmail dot com>
- Cc: binutils <binutils at sourceware dot org>
- Date: Mon, 12 Nov 2007 10:32:42 +0000
- Subject: Re: How to expand the `bss`section and fill it zeros when 'objcopy'ing?
- References: <200711121539456225128@gmail.com>
Hi PRC,
I want to create a raw binary file from a ELF image. I invoke the command:
mips-elf-objcopy -O binary -j ".text" -j ".data" -j ".bss" my.exe my.bin
Please note that when you are reporting a problem like this, it helps to
mention which version of the binutils you are using. Problems which exist in
older versions of the binutils are often fixed in newer versions.
But the size of the output `my.bin` is not the sum of sizes of ".text", ".data" and ".bss".
It is the sum of ".text" and ".data", excluding ".bss".
How can I make objcopy expand the ".bss" section and fill it zeros?
By telling it that the .bss section has contents that should be loaded. Like this:
mips-elf-objcopy -O binary -j .text -j .data -j .bss \
--set-section-flags .bss=alloc,load,contents \
my.exe my.bin
Cheers
Nick