This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to expand the `bss`section and fill it zeros when 'objcopy'ing?


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]