Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

#computers #os #process

Program memory layout


An object file is divided into sections containing different types of data1.

sectiondescription
.textwhere code live, as said above. objdump -drS .process.o will show you th
.datainitialized data: global tables, variables, etc. objdump -s -j .data .process.o will hexdump
.bss (block started by symbol (or Better Save Space) [^4]). uninitialized arrays and variables. Filled with zeros, or only the length of the section in some platforms. and
.rodatacontains read-only initialized data, is packed into the same segment that contains the .text sec
.comment .notejust comments put there by the compiler/linker too
.stab .stabstrdebugging symbols & similar infor
.initcode running before
.finiCode run after
.pltindirect calls to dynamically linked
.symtabs

Yo can use readelf or objdump to inspect binaries.

Some info was also taken from osdev wiki 2.

All this section story is strongly related to how the linker and the compiler 1a-compilation work3 1.



  1. https://gcc.gnu.org/onlinedocs/gcc-4.0.4/gccint/Sections.html ↩ ↩2

  2. https://wiki.osdev.org/ELF ↩

  3. https://lwn.net/Articles/531148 ↩