Programs
What is a program
Code - Instructions that make up the program Data - Any data compiled into the program BBS - Any uninitialised data
Address
Can put this anywhere in memory, as they are all just bytes
- Code - Bytes that make up the opcodes for the programs instructions
- Data - Bytes that represent the data
- BSS - Bytes that we know will need to store things in at some point Providing the address are know the program would work fine, tend to be a little more structured when creating programs
Program Structure
- Find all the code is grouped together in one section (
.text
section) - Followed by all the data grouped into another section (
.data
section) - Followed by the BSS
Benefits
- Combining the sections enables the OS to do nice things
- Code can be shared between multiple instances of the same program
- Can make the code sections of memory read-only
- Can make the data sections non-executable
Libraries
- Same approach is take with static libs
- Code, data and BSS sections linked in which program code
- Libraries are often just a collection of object files
- Windows uses DLLs
Executable File
- Each section of the final linked program is then stored on disk
- No need to store the BSS