From 87b286c358bce7fea6b6ed96422f427fdbd92818 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Mon, 16 Dec 2024 08:06:26 -0700 Subject: [PATCH] Notes on object files. --- .../plugins/obsidian-to-anki-plugin/data.json | 11 +- .../_journal/{2024-12-15.md => 2024-12-16.md} | 2 +- notes/_journal/2024-12/2024-12-15.md | 9 ++ notes/geometry/cartesian.md | 4 +- notes/linkers/index.md | 101 ++++++++++++- notes/linkers/object-files.md | 138 ++++++++++++++++++ notes/linkers/static.md | 104 ------------- 7 files changed, 256 insertions(+), 113 deletions(-) rename notes/_journal/{2024-12-15.md => 2024-12-16.md} (62%) create mode 100644 notes/_journal/2024-12/2024-12-15.md create mode 100644 notes/linkers/object-files.md delete mode 100644 notes/linkers/static.md diff --git a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json index 389f126..7cd0e1c 100644 --- a/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json +++ b/notes/.obsidian/plugins/obsidian-to-anki-plugin/data.json @@ -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": [ diff --git a/notes/_journal/2024-12-15.md b/notes/_journal/2024-12-16.md similarity index 62% rename from notes/_journal/2024-12-15.md rename to notes/_journal/2024-12-16.md index 2f07316..15c3faa 100644 --- a/notes/_journal/2024-12-15.md +++ b/notes/_journal/2024-12-16.md @@ -1,5 +1,5 @@ --- -title: "2024-12-15" +title: "2024-12-16" --- - [ ] Anki Flashcards diff --git a/notes/_journal/2024-12/2024-12-15.md b/notes/_journal/2024-12/2024-12-15.md new file mode 100644 index 0000000..067ab39 --- /dev/null +++ b/notes/_journal/2024-12/2024-12-15.md @@ -0,0 +1,9 @@ +--- +title: "2024-12-15" +--- + +- [x] Anki Flashcards +- [x] KoL +- [x] OGS +- [ ] Sheet Music (10 min.) +- [ ] Korean (Read 1 Story) \ No newline at end of file diff --git a/notes/geometry/cartesian.md b/notes/geometry/cartesian.md index b824570..c24d1e9 100644 --- a/notes/geometry/cartesian.md +++ b/notes/geometry/cartesian.md @@ -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). - + END%% %%ANKI diff --git a/notes/linkers/index.md b/notes/linkers/index.md index 53d0a37..c7566df 100644 --- a/notes/linkers/index.md +++ b/notes/linkers/index.md @@ -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. + +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. \ No newline at end of file diff --git a/notes/linkers/object-files.md b/notes/linkers/object-files.md new file mode 100644 index 0000000..5e54205 --- /dev/null +++ b/notes/linkers/object-files.md @@ -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. + +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 + +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 + +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 + +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 + +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. + +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. + +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. + +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. + +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. + +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 + +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 + +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 + +END%% + +## Bibliography + +* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. \ No newline at end of file diff --git a/notes/linkers/static.md b/notes/linkers/static.md deleted file mode 100644 index 87115f1..0000000 --- a/notes/linkers/static.md +++ /dev/null @@ -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. - -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. \ No newline at end of file