[cfe-dev] .bss section in elf file

Joerg Sonnenberger joerg at britannica.bec.de
Sat Apr 5 06:08:16 PDT 2014


On Fri, Apr 04, 2014 at 05:23:37AM -0700, TheMask wrote:
> If I understand corretly, by creating a section of .bss type (as below code
> example) the write/read area of the .bss section is from section's offset
> in the file to N and in this case phdr.p_memsz gets incremented by N bytes
> and it's up to operating system/kernel zero this memory area. Is my
> intepretation right?

I can't parse your question. The .bss section has no content. At link
time, it gets merged with the .data section into a single PT_LOAD
segment. The reserved VA space for that segment is the sum of .bss and
.data size. The space in the ELF file is the size of the .data section.
The kernel or dynamic linker will map the part from the file that
represents the .data section with mmap as copy-on-write, followed by a
anonymous mapping for the .bss part. The kernel is responsible for
zeroing the latter part. Does that answer your question?

Joerg



More information about the cfe-dev mailing list