--- title: Linkers TARGET DECK: Obsidian::STEM FILE TAGS: linker tags: - linker --- ## Overview To build an executable, a linker must perform two main tasks: 1. **Symbol resolution**. The linker must associate each symbol reference with exactly one symbol definition. 2. **Relocation**. The linker must relocate code and data sections by associating a memory location with each symbol definition, and then modifying all of the references to those symbols so that they point to this memory location. The linker blindly performs relocations using detailed instructions generated by the assembler called **relocation entries**. %%ANKI Basic According to Bryant et al., a static linker must perform what two tasks? Back: Symbol resolution and relocation. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Basic Which of symbol resolution or relocation happens first? Back: Symbol resolution. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Basic What is the goal of symbol resolution? Back: To associate each symbol reference with exactly one symbol definition. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Basic What is the goal of relocation? Back: To assign a memory location to each symbol and update references accordingly. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Basic *Why* must relocation happen after symbol resolution? Back: We should not assign multiple addresses to the same symbol. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Cloze {Symbol resolution} associates each {symbol reference} with exactly one {symbol definition}. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Cloze {Relocation} assigns a {memory location} to each symbol and {updates references} accordingly. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Basic What does it mean for a linker to relocate a code and/or data section? Back: It associates a memory location with each symbol definition and updates references accordingly. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Basic What is emitted by the assembler to help the linker relocate sections? Back: Relocation entries. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Cloze The assembler outputs {relocation entries} to guide the linker during {relocation}. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% %%ANKI Cloze The {1:assembler} outputs relocation entries to guide the {1:linker} during relocation. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. END%% ## Bibliography * Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.