Skip to content

Commit 6566d6e

Browse files
authored
Another round of typo fixes (#84)
* Fix typo in useful resources chapter * Minor improvements to elf chapter * Requested changes
1 parent d05ed9b commit 6566d6e

3 files changed

Lines changed: 14 additions & 15 deletions

File tree

09_Loading_Elf/01_Elf_Theory.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ All structs in the base ELF spec are defined using these types, and so we will u
3131

3232
The format has four main sections:
3333

34-
- *The ELF header*: This contains the magic number used to identify it as an ELF, as well as information about the architecture the ELF was compiled for, the target operating system and other useful info.
34+
- *The ELF header*: This contains the magic number used to identify it as an ELF, as well as information about the architecture the ELF was compiled for, the target operating system and other useful info. This is identified as the `e_ident` field.
3535
- *The data blob*: The bulk of the file is made up of this blob. This is a big binary blob containing code, all kinds of data, some string tables and sometimes debugging information. All program data lives here.
3636
- *Section headers*: Each header has a name and some metadata associated with it, and describes a region of the data blob. Section names usually begin with a dot (`.`), like `.strtab` which refers to the string table. Section headers are for other software to parse the ELF and understand its structure and contents.
3737
- *Program headers*: These are for the program loader (what we're going to write). Each program header has a type that tells the loader how to interpret it, as well as specifying a range within the data blob. These ranges in the data blob can overlap (or often cover the same area as some section header ranges) ranges described by section headers.
@@ -98,7 +98,7 @@ This type means that we are expected to load the contents of this program header
9898
To load our simple, statically-linked, program the process is as follows:
9999
100100
1) Load the ELF file in memory somewhere.
101-
2) Validate the ELF header by checking the machine type matches what we expect (is this an x86_64 program?).
101+
2) Validate the ELF header by checking the machine type matches what we expect (is this an x86_64 program?), this is done by parsing the `e_ident` member.
102102
3) Find all program headers with the `PT_LOAD` type.
103103
4) Load each program header: we'll cover this shortly.
104104
5) Jump to the start address defined in the ELF header.

09_Loading_Elf/02_Loading_And_Running.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ In the previous chapter we looked at the details of loading program headers, but
1515
- First a copy of the ELF file to be loaded is needed. The recommended way is to load a file via the VFS, but it could be a bootloader module or even embedded into the kernel.
1616
- Then once the ELF is loaded, we need verify that its header is correct. Also check the architecture (machine type) matches the current machine, and that the bit-ness is correct (dont try to run a 32-bit program if you dont support it!).
1717
- Find all the loadable program headers for the ELF, we'll need those in a moment.
18-
- Create a new address space for the program to live in. This usually involves creating a new VMM instance, but the specifics will vary depending on your design. Don't forget to keep the kernel mappings in the higher half!
18+
- Create a new address space for the program to live in. This usually involves creating a new process with a new VMM instance, but the specifics will vary depending on your design. Don't forget to keep the kernel mappings in the higher half!
1919
- Copy the loadable program headers into this new address space. Take care when writing this code, as the program headers may not be page-aligned:. Don't forget to zero the extra bytes between `memsz` and `filesz`.
2020
- Once loaded, set the appropriate permission on the memory each program header lives in: the write, execute (or no-execute) and user flags.
21-
- Now we'll need to create a new thread to act as the main thread for this program, and set its entry point to the `e_entry` field in the ELF header. This field is the start function of the program. You'll also need to create a stack in the memory space of this program for the thread to use, if this wasnt already done as part of your thread creation.
21+
- Now we'll need to create a new thread to act as the main thread for this program, and set its entry point to the `e_entry` field in the ELF header. This field is the start function of the program. You'll also need to create a stack in the memory space of this program for the thread to use, if this wasnt already done as part of our thread creation.
2222

2323
If all of the above are done, then the program is ready to run! We now should be able to enqueue the main thread in the scheduler and let it run.
2424

99_Appendices/H_Useful_Resources.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This appendix is a collection of links we found useful developing our own kernel
2727
- Broken Thron Osdev Book Series Chapter 16 PIC, PIT and Exceptions: [http://www.brokenthorn.com/Resources/OSDev16.htm](http://www.brokenthorn.com/Resources/OSDev16.html)
2828
- Osdev Wiki Ps2 Keyboard page: [https://wiki.osdev.org/PS/2_Keyboard](https://wiki.osdev.org/PS/2_Keyboard)
2929
- Osdev Wiki Interrupts page: [https://wiki.osdev.org/IRQ#From_the_keyboard.27s_perspective](https://wiki.osdev.org/IRQ#From_the_keyboard.27s_perspective)
30-
- Osdev Wiki 8042 Controller pagepage: [https://wiki.osdev.org/"8042"_PS/2_Controller#Translation](https://wiki.osdev.org/%228042%22_PS/2_Controller#Translation)
30+
- Osdev Wiki 8042 Controller pagepage: [https://wiki.osdev.org/8042_PS/2_Controller#Translation](https://wiki.osdev.org/%228042%22_PS/2_Controller#Translation)
3131
- Scancode sets page: [https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html#scancodesets](https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html#scancodesets)
3232
- Brokenthorn Book Series Chapter 19 Keyboard programming: [http://www.brokenthorn.com/Resources/OSDev19.html](http://www.brokenthorn.com/Resources/OSDev19.html)
3333

@@ -43,13 +43,13 @@ This appendix is a collection of links we found useful developing our own kernel
4343
## Memory Management
4444

4545
- Intel Software developer's manual Vol 3A Paging Chapter
46-
- Osdev Wiki page for Page Frame Allocation: [https://wiki.osdev.org/Page_Frame_Allocation](https://wiki.osdev.org/Page_Frame_Allocation)
46+
- Osdev Wiki page for Page Frame Allocation: [https://wiki.osdev.org/Page_Frame_Allocation](https://wiki.osdev.org/Page_Frame_Allocation)
4747
- Writing an Os in Rust by Philipp Oppermann Memory management: [https://os.phil-opp.com/paging-introduction/](https://os.phil-opp.com/paging-introduction/)
4848
- Broken Thorn Osdev Book Series, Chapter 18: The VMM [http://www.brokenthorn.com/Resources/OSDev18.html](http://www.brokenthorn.com/Resources/OSDev18.html)
4949

5050
## Scheduling
5151

52-
- Osdev Wiki page for Scheduling Algirthm: [https://wiki.osdev.org/Scheduling_Algorithms](https://wiki.osdev.org/Scheduling_Algorithms)
52+
- Osdev Wiki page for Scheduling Algorithm: [https://wiki.osdev.org/Scheduling_Algorithms](https://wiki.osdev.org/Scheduling_Algorithms)
5353
- Operating System Three Easy Pieces (Book): [https://pages.cs.wisc.edu/~remzi/OSTEP/](https://pages.cs.wisc.edu/~remzi/OSTEP/)
5454
- Broken Thorn Osdev Book Series: [http://www.brokenthorn.com/Resources/OSDev25.html](http://www.brokenthorn.com/Resources/OSDev25.html)
5555
- Writing an Os in Rust by Philip Opperman Multitasking: [https://os.phil-opp.com/async-await/](https://os.phil-opp.com/async-await/)
@@ -58,7 +58,6 @@ This appendix is a collection of links we found useful developing our own kernel
5858

5959
- Intel Software developer's manual Vol 3A Protection Chapter
6060
- Wiki Osdev Page for Ring 3: [https://wiki.osdev.org/Getting_to_Ring_3](https://wiki.osdev.org/Getting_to_Ring_3)
61-
- JamesMolloy User mode chapter: [http://www.jamesmolloy.co.uk/tutorial_html/10.-User Mode.html](http://www.jamesmolloy.co.uk/tutorial_html/10.-User%20Mode.html)
6261
- Default calling conventions for different compilers: [https://www.agner.org/optimize/#manuals](https://www.agner.org/optimize/#manuals)
6362

6463
## IPC
@@ -70,7 +69,6 @@ This appendix is a collection of links we found useful developing our own kernel
7069

7170
## Virtual File System
7271

73-
- JamesMolloy VFS chapter: [http://www.jamesmolloy.co.uk/tutorial_html/8.-The VFS and the initrd.html](http://www.jamesmolloy.co.uk/tutorial_html/8.-The%20VFS%20and%20the%20initrd.html)
7472
- Wiki Osdev page for USTAR: [https://wiki.osdev.org/USTAR](https://wiki.osdev.org/USTAR)
7573
- Tar (Wikipedia): [https://en.wikipedia.org/wiki/Tar_(computing)](https://en.wikipedia.org/wiki/Tar_\(computing\))
7674
- Osdev Wiki page for VFS: [https://wiki.osdev.org/VFS](https://wiki.osdev.org/VFS)
@@ -97,17 +95,18 @@ This appendix is a collection of links we found useful developing our own kernel
9795

9896
## Communities
9997

100-
- Osdev Fourm: [https://forum.osdev.org/](https://forum.osdev.org/)
101-
- Operating System Developmen on Reddit: [https://www.reddit.com/r/osdev/](https://www.reddit.com/r/osdev/)
102-
- Osdev Discord server: [https://discord.gg/osdev](https://discord.gg/osdev)
98+
- Osdev Forum: [https://forum.osdev.org/](https://forum.osdev.org/)
99+
- Operating System Development on Reddit: [https://www.reddit.com/r/osdev/](https://www.reddit.com/r/osdev/)
100+
- OSdev Discord server: [https://discord.gg/osdev](https://discord.gg/osdev)
101+
- Friendly Operating System Devs: [https://discord.gg/Vwudfxx8Sp](https://discord.gg/Vwudfxx8Sp)
103102

104103
## Books and Manuals
105104

106105
- Gnu.org TAR manual page: [https://www.gnu.org/software/tar/manual/html_node/Standard.html](https://www.gnu.org/software/tar/manual/html_node/Standard.html)
107106
- Broken Thorne Osdev Book Series Chapter 22 VFS: [http://www.brokenthorn.com/Resources/OSDev22.html](http://www.brokenthorn.com/Resources/OSDev22.html)
108107
- Operating System Three Easy Pieces (Book): [https://pages.cs.wisc.edu/~remzi/OSTEP/](https://pages.cs.wisc.edu/~remzi/OSTEP/)
109108
- Operating Systems Design And Implementation by Andres S. Tanenbaum. Difficult to find as of today, but if you can it's an excellent resource on the minix kernel.
110-
- Thinks Os By Allen B. Downey: [https://greenteapress.com/thinkos/](https://greenteapress.com/thinkos/)
111-
- Xv6 is a modern rewrite of v6 unix, for teaching purposes. It comes with an accompanying book which walks through each part of the source code. It was later ported to risc-v, but the x86 version is still available (but no longer actively maintained). [https://pdos.csail.mit.edu/6.S081/2020/xv6/book-riscv-rev1.pdf](https://pdos.csail.mit.edu/6.S081/2020/xv6/book-riscv-rev1.pdf)
109+
- Think Os By Allen B. Downey: [https://greenteapress.com/thinkos/](https://greenteapress.com/thinkos/)
110+
- Xv6 is a modern rewrite of v6 unix, for teaching purposes. It comes with an accompanying book which walks through each part of the source code. It was later ported to risc-v, but the x86 version is still available (but no longer actively maintained): [https://pdos.csail.mit.edu/6.S081/2020/xv6/book-riscv-rev1.pdf](https://pdos.csail.mit.edu/6.S081/2020/xv6/book-riscv-rev1.pdf)
112111

113-
An interesting github repository with a lot of resources about operating systems, like guides, tutorials, hobby kernels, interesting project is the `awesome-os` rpository by @jubalh available here: [https://github.com/jubalh/awesome-os](https://github.com/jubalh/awesome-os)
112+
An interesting github repository with a lot of resources about operating systems like guides, tutorials, hobby kernels, is the `awesome-os` project by @jubalh available here: [https://github.com/jubalh/awesome-os](https://github.com/jubalh/awesome-os)

0 commit comments

Comments
 (0)