[cfe-dev] .bss section in elf file

Joerg Sonnenberger joerg at britannica.bec.de
Sat Apr 5 19:43:46 PDT 2014


On Sat, Apr 05, 2014 at 06:09:58PM -0700, TheMask wrote:
> 1) How does it differ if I'm working with a static executable and
> using /SHT_NOBITS /i.e, a section not a segment?

Segments are used by the ELF loader (kernel or dynamic linker). Sections
are normally used by tools operating on object files. A segment is
typically a collection of multiple sections. Different granularity.

> 2) by the "room" of a section (in memory): Is it the end of .data + .bss
> section/segment address to count of bytes I've set in sh_size

.bss will be placed at the end of the data segment. Exact start address
is "size of data rounded up by bss alignment". You can compare address
and address + size of .data, .bss and the second (writeable) LOAD
segment in the output of readelf -lS /bin/cat.

> 3) Also, can I play with static executables, say, use .rodata/.data/
> .bss/.text sections before I make it dynamic? ie. is there something
> I couldn't do by using static but dynamic can do(except use a dynamic
> library, of couse) ?

Static executables are simpler in nature. The most basic difference is
that they don't contain runtime relocations. There are some others, but
that goes into quite a bit more into details.

> and I'd love if you have a good resource about ELF file format. I want
> to understand these stuff before try to put my hands on llvm source code.

Linkers and Loaders is still a decent starting point, I think. You can
find it either in a good library, Amazon or online via
http://www.iecc.com/linker/ The wikipedia page for ELF has some further
references, e.g. to the original SYSV specification for ELF.

Joerg



More information about the cfe-dev mailing list