Every program is split into multiple sections. In general, these are:
They are just the defaults, there can be many more sections in a binary. For example our sample code contains the following different sections.
$ objdump -h a.out
Most of the section compiled into the binary is either empty or just debugging
information. The most important of the sections are the
.text section contains the executable instructions. This data can
be viewed using
$ # disassemble only the .text section $ objdump -d -j .text a.out
The next section
.bss will contain uninitialized data. The C standard say that
all uninitialized global variables much be set to zero. So instead of wasting
space in the binary with zeroes, it contains only the size of the
section, as the kernel provided memory will always be initialized to zero. The
other sections too are not present in the binary as they are available during
the run time, like the stack and the heap sections. The symbols present in
various sections can be found using the
$ nm a.out
The type of symbol is printed in the second column.
D refers to the symbols in
In this section we have seen one more new term - the binary loader. This is the dynamic loader which links the executable with the shared libraries(.so) at run time. This is the topic of the next section.Continue reading other posts in the series, "Life of a process"
Site design and logo and content © fossix.org