10-06-2014, 03:27 PM
Assemblers, Linkers & Loaders
Assemblers, Linkers.pdf (Size: 57.82 KB / Downloads: 190)
Translation Hierarchy
• Compiler
– Translates high-level language program into
assembly language (CS 440)
• Assembler
– Converts assembly language programs into
object files
• Object files contain a combination of machine
instructions, data, and information needed to place
instructions properly in memory
Assemblers
• Assemblers need to
– translate assembly instructions and pseudo-instructions
into machine instructions
– Convert decimal numbers, etc. specified by
programmer into binary
• Typically, assemblers make two passes over the
assembly file
– First pass: reads each line and records labels in a
symbol table
– Second pass: use info in symbol table to produce actual
machine code for each line
Object file format
• Object file header describes the size and position of the
other pieces of the file
• Text segment contains the machine instructions
• Data segment contains binary representation of data in
assembly file
• Relocation info identifies instructions and data that depend
on absolute addresses
• Symbol table associates addresses with external labels and
lists unresolved references
• Debugging info
Linker
• Tool that merges the object files produced by
separate compilation or assembly and creates an
executable file
• Three tasks
– Searches the program to find library routines used by
program, e.g. printf(), math routines,…
– Determines the memory locations that code from each
module will occupy and relocates its instructions by
adjusting absolute references
– Resolves references among files