Computer Architecture: Running A Program Khiyam Iftikhar
Computer Architecture: Running A Program Khiyam Iftikhar
Computer Architecture: Running A Program Khiyam Iftikhar
Running a Program
Khiyam Iftikhar
Steps Involved
Compiler and Assembler
• Compiler converts a higher level language
code to assembly code
• Assemble converts assembly code to machine
code and generates object file which is a
combination of machine language
instructions, data and information to place
properly in memory
Compiler Example: C Code
Compiler Example: Compiled Code
Object File Types
• Relocatable object file. Contains binary code and
data in a form that can be combined with other
relocatable object files at compile time to create an
executable object file.
• Executable object file. Contains binary code and data
in a form that can be copied directly into memory
and executed.
• Shared object file A special type of relocatable object
file that can be loaded into memory and linked
dynamically, at either load time or run time.
Relocatable Object File
• Object file format standard for unix is ELF format. We will only
study basic requirements for an object file
• Object file consists of 6 distinct parts
• Header : Size and position of other parts of file
• Text Segment: Machine Language Code
• Static Data Segment:
• Relocation information: identifies instructions and data words
that depend upon absolute addresses
• Symbol Table: symbols from code and data
• Debugging information: how the code was compiles; relating
HLL code and assembly code
Symbol Table
• It contains the information regarding symbol
which includes
– Name
– Type(Func or Data)
– index (To determine segment)
– Offset (Address inside segment)
– Value
– Size
Assembler
• Assembler makes two passes through the
assembly code
– 1st Pass: Assign Instruction addresses and finds all
the symbols and global variable names and keeps
their addresses in a symbol table.
Assembler:1 Pass Code
st