Memory (Part 3)
The previous tip showed how a load file is created from source and library files. Here's the part of the figure in that tip that shows the load file:

The contents of the sections in this load file are as follows:
- Data section, which contains static variables and variables initialized outside of a function. Here is a small example program:
int my_var1 = 10;
void main ()
{
static int my_var2 = 1;
int my_var3;
my_var3 = my_var1 + my_var2;
printf("here's what I've got: %i\n", my_var3);
}
The data section contains the my_var1 and my_var2 variables. The memory for the my_var3 variable is dynamically and automatically allocated within the stack by your program's run time system.
- Symbol table section, which contains addresses (usually offsets) to where routines and variables reside.
- Machine code section, which contains an intermediate binary representation of your program. (It is intermediate because addresses are not yet resolved.)
- Header section, which contains information about the size and location of information in all other sections of the object file.
When the linker creates the load file from the object and library files, it
interweaves these sections into one file. The linking operation creates
something that your operating system can load into memory. The following
figure shows this process.

You can find tips that we've already sent out in our Tip Archive
Help us improve these tips!