Notes on object files.

main
Joshua Potter 2024-12-16 08:06:26 -07:00
parent 5b1f8e6dee
commit 87b286c358
7 changed files with 256 additions and 113 deletions

View File

@ -946,7 +946,7 @@
"_journal/2024-11/2024-11-08.md": "806bbade5f8339579287687f9433334e",
"_journal/2024-11/2024-11-07.md": "434ec3f15d7065ea740127aa8477dd17",
"x86-64/directives.md": "019c1c1d04efb26c3e8758aac4543cc7",
"geometry/cartesian.md": "94730b4de278495430d0c7951ed3e17c",
"geometry/cartesian.md": "1977d6fd05109456cf1824822b836b02",
"geometry/index.md": "cac68c1b624dbb0552e56cce47bcc21d",
"_journal/2024-11-10.md": "5478337fd2017b99d0b359713a511e66",
"_journal/2024-11/2024-11-09.md": "46f3a640223ef533f4523837b67b57c3",
@ -1005,7 +1005,7 @@
"_journal/2024-12-08.md": "5662897539b222db1af45dcd217f0796",
"_journal/2024-12/2024-12-07.md": "bfb6c4db0acbacba19f03a04ec29fa5c",
"linkers/static.md": "cc56ddfc33f605d26b954ec242abc4cf",
"linkers/index.md": "84ffda7dddc04d2843b98224f1b7a0e1",
"linkers/index.md": "73b07789a48be8a611941d50ae4f3831",
"_journal/2024-12-09.md": "8988f0e8f0060f4b86d17e0bc4e7ff7e",
"_journal/2024-12/2024-12-08.md": "5662897539b222db1af45dcd217f0796",
"_journal/2024-12-10.md": "c12d380d24d7d1dc2e74a57a1b79399e",
@ -1018,10 +1018,13 @@
"encoding/uri.md": "394abe477b882e1414dd2fb151fea823",
"encoding/xml.md": "5b345c09ac60821f88ed5b592e411df6",
"encoding/rdf.md": "b32d6c0a2249794da89d9c7fb7ca325e",
"_journal/2024-12-15.md": "bc05b98f4e4d30c7f2db73f1cef9d806",
"_journal/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a",
"_journal/2024-12/2024-12-14.md": "d2223f90fd1ce3d82a4fbb6828a1ec56",
"_journal/2024-12/2024-12-13.md": "d2223f90fd1ce3d82a4fbb6828a1ec56",
"_journal/2024-12/2024-12-12.md": "59e71caa4e9ebdb11a7c7549c33bed20"
"_journal/2024-12/2024-12-12.md": "59e71caa4e9ebdb11a7c7549c33bed20",
"linkers/object-files.md": "77767f310330b8650a5023dd0522226c",
"_journal/2024-12-16.md": "77c27920d5b44b6315c2ea22b990eefc",
"_journal/2024-12/2024-12-15.md": "be66c8808d8bb66d4e7b91db7c93c94a"
},
"fields_dict": {
"Basic": [

View File

@ -1,5 +1,5 @@
---
title: "2024-12-15"
title: "2024-12-16"
---
- [ ] Anki Flashcards

View File

@ -0,0 +1,9 @@
---
title: "2024-12-15"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -326,10 +326,10 @@ Reference: James Jones, “Shifting, Reflecting, and Stretching Graphs,” acces
END%%
%%ANKI
Basic
Cloze
A {vertical} scaling multiplies/divides the {$y$}-coordinates of a graph.
Reference: James Jones, “Shifting, Reflecting, and Stretching Graphs,” accessed December 6, 2024, [https://people.richland.edu/james/lecture/m116/functions/translations.html](https://people.richland.edu/james/lecture/m116/functions/translations.html).
<!--ID: 1733522558496-->
<!--ID: 1734299397501-->
END%%
%%ANKI

View File

@ -1,7 +1,104 @@
---
title: Linkers
TARGET DECK: Obsidian::STEM
FILE TAGS: linkers
FILE TAGS: linker
tags:
- linkers
- 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.
<!--ID: 1733671136073-->
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.
<!--ID: 1733671136078-->
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.
<!--ID: 1733671136081-->
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.
<!--ID: 1733671136084-->
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.
<!--ID: 1733671136088-->
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.
<!--ID: 1733671136092-->
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.
<!--ID: 1733671136097-->
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.
<!--ID: 1733671136102-->
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.
<!--ID: 1733671136107-->
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.
<!--ID: 1733671136112-->
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.
<!--ID: 1733671136117-->
END%%
## Bibliography
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.

View File

@ -0,0 +1,138 @@
---
title: Object Files
TARGET DECK: Obsidian::STEM
FILE TAGS: linker::object-file
tags:
- linker
- object-file
---
## Overview
Object files come in three forms:
1. **Relocatable object files**. Contains binary code and data in a form that can be combined with other relocatable object files at compile time.
2. **Executable object files**. Contains binary code and data in a form that can be copied directly into memory and executed.
3. **Shared object files**. A special type of relocatable object file that can be loaded into memory and linked dynamically, at either load time or run time.
%%ANKI
Basic
What are the two types of object files?
Back: Relocatable and executable.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734356868367-->
END%%
%%ANKI
Basic
Relocatable object files are outputs of which compiler driver component?
Back: The assembler.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1734356868394-->
END%%
%%ANKI
Basic
Executable object files are outputs of which compiler driver component?
Back: The linker.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1734356868399-->
END%%
%%ANKI
Basic
Relocatable object files are inputs into which compiler driver component?
Back: The linker.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1734356868403-->
END%%
%%ANKI
Basic
Executable object files are inputs into which compiler driver component?
Back: N/A.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17
<!--ID: 1734356868406-->
END%%
%%ANKI
Cloze
A {shared} object file is a special case of a {relocatable} object file.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734356868428-->
END%%
An **object module** is a sequence of bytes whereas an **object file** is an object module stored on disk.
%%ANKI
Basic
What is an object module?
Back: A sequence of bytes.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734356868413-->
END%%
%%ANKI
Basic
In terms of object modules, what is an object file?
Back: An object module stored on disk.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734356868418-->
END%%
%%ANKI
Basic
What distinguishes an object module from an object file?
Back: An object file is an object module stored on disk.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734356868423-->
END%%
%%ANKI
Basic
In what way is the term "object file" misused by Bryant et al.?
Back: Technically this term only refers to object modules on disk.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1734356868433-->
END%%
Object files are organized to specific **object file formats**:
* Windows uses the PE (Portable Executable) format.
* Mac OS-X uses the Mach-O format.
* Modern x86-64 Linux systems use the ELF (Executable and Linkable Format) format.
%%ANKI
Basic
What object file format do x86-64 Linux machines typically use?
Back: ELF.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: x86-64
<!--ID: 1734356868437-->
END%%
%%ANKI
Basic
What is the ELF object file format an acronym for?
Back: **E**xecutable and **L**inkable **F**ormat.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: x86-64
<!--ID: 1734356868442-->
END%%
%%ANKI
Basic
What is ELF an example of?
Back: An object file format.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: x86-64
<!--ID: 1734356868446-->
END%%
## Bibliography
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.

View File

@ -1,104 +0,0 @@
---
title: Static Linkers
TARGET DECK: Obsidian::STEM
FILE TAGS: linkers::static
tags:
- linkers
---
## 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.
<!--ID: 1733671136073-->
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.
<!--ID: 1733671136078-->
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.
<!--ID: 1733671136081-->
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.
<!--ID: 1733671136084-->
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.
<!--ID: 1733671136088-->
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.
<!--ID: 1733671136092-->
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.
<!--ID: 1733671136097-->
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.
<!--ID: 1733671136102-->
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.
<!--ID: 1733671136107-->
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.
<!--ID: 1733671136112-->
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.
<!--ID: 1733671136117-->
END%%
## Bibliography
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.