lecture 9 Flashcards
Assemble, Link, and load
given assembly program (pl.s), what will the assembler do?
assembler will create one relocatable object file
pl.s –> pl.o
what format is the relocatable object file?
bytes are in Executable Linkable File (ELF) format
what happens to each machine instruction in the assembly program when translated to ELF format?
each machine instruction generated by the assembler gets assigned to a specific ELF section with a temporary memory address
ELF sections
.text
.rodata
.data
.symtab
.reltext
.reldata
what gets placed in the .text section?
machine instructions (ie your program)
what gets placed in the .rodata section?
read only data (ie constants)
what gets placed in the .data section?
initialized global and static variables
what gets placed in the .symtab section?
symbol table
- holds the name and address
locations of functions and
global/static variables
what gets placed in the .reltext section?
relocation info for .text section
- linker will relocate unresolved
instructions and addresses (later
step) –> linker must resolve these
to create an executable
what gets placed in the .reldata section?
relocation info for .data section
- linked will relocate unresolved
data and addresses (later step) –>
linker must resolve these to
create an executable
what are the 3 types of ELF binary object files?
- relocatable object file (only created by the assembler, .o)
- executable object file (a.out)
- shared object file (.so)
what counts as symbols in the .symtab?
name of function
global variable
static variable
what is included in a symbol table entry?
symbol name
section symbol (will go in either .text or .data)
32-bit address in memory
pl.o: * assembly lang (in c for example)
int sum (int *a, int n);
int array[2] = {1, 2};
int main() {
int val = sum(array, 2);
return val;
}
.symtab section:
.symtab (pl) symbol | section | address -------------------------------------------- main | .text | ? sum | .text | ? array | .data | ?
what does the assembler do first?
assembler identifies all symbols in the assembly program and updates .symtab
pl.o: * assembly lang (in c for example)
int sum (int *a, int n);
int array[2] = {1, 2};
int main() {
int val = sum(array, 2);
return val;
}
.symtab section:
.symtab (pl) symbol | section | address -------------------------------------------- main | .text | ? sum | .text | ? array | .data | ?
what does the ‘?’ mean under address?
for those symbols –> they have unknown address locations within the program
*must be resolved by either assembler (second pass) or linker (next step)