Probing static memory layout
The tools used for inspecting the static memory layout usually work on the object files. To get some initial insight, we'll start with an example, example 4.1, which is a minimal C program that doesn't have any variable or logic as part of it:
int main(int argc, char** argv) { return 0; }
Code Box 4-1 [ExtremeC_examples_chapter4_1.c]: A minimal C program
First, we need to compile the preceding program. We compile it in Linux using gcc
:
$ gcc ExtremeC_examples_chapter4_1.c -o ex4_1-linux.out $
Shell Box 4-1: Compiling example 4.1 using gcc in Linux
After a successful compilation and having the final executable binary linked, we get an executable object file named ex4_1-linux.out
. This file contains a predetermined static memory layout that is specific to the Linux operating system, and it will exist in all future processes spawned based on this executable file.
The size
command is the first tool that we want to introduce...