public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* How to expand the `bss`section and fill  it zeros when 'objcopy'ing?
@ 2007-11-12  7:40 PRC
  2007-11-12 10:32 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: PRC @ 2007-11-12  7:40 UTC (permalink / raw)
  To: binutils

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

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?

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to expand the `bss`section and fill  it zeros when 'objcopy'ing?
  2007-11-12  7:40 How to expand the `bss`section and fill it zeros when 'objcopy'ing? PRC
@ 2007-11-12 10:32 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2007-11-12 10:32 UTC (permalink / raw)
  To: PRC; +Cc: binutils

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-11-12 10:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-12  7:40 How to expand the `bss`section and fill it zeros when 'objcopy'ing? PRC
2007-11-12 10:32 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).