This is the mail archive of the binutils@sources.redhat.com 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: Question concerning objcopy an elf file into a raw binary file


Jie Zhang <zhangjie@magima.com.cn> writes:

>   [ 3] .bss              NOBITS          60003400 000074 000064 00  WA
> 0   0  4

> Program Headers:
>   Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD           0x000074 0x60003400 0x60003400 0x00000 0x00064 RW  0x4
>   LOAD           0x000074 0x60003464 0x60003464 0x019e0 0x019e0 RWE 0x4

> I expect that the memory dump will start at 60003400, but actually it
> starts at 60003464. It seems that objcopy does not actually copy .bss
> section. But .bss section is in a LOAD type segment and should, I
> think, be part of the memory dump.

.bss has NOBITS, so there is no data to put into the binary file.
It's true that .bss is in a LOAD type segment, but the file size of
that segment is zero.

When not using an operating system loader, it's normal for a program
to have to zero out the BSS in the startup code.  In most cases, this
is more efficient than copying a bunch of zeroes around.

Ian


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