You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 09_Loading_Elf/02_Loading_And_Running.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,9 +18,9 @@ In the previous chapter we looked at the details of loading program headers, but
18
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!
19
19
- 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`.
20
20
- 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 our 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 wasn't already done as part of our thread creation.
22
22
23
-
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.
23
+
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.
24
24
25
25
### Verifying an ELF file
26
26
@@ -35,8 +35,8 @@ When verifying an ELF file there are few things we need to check in order to dec
35
35
|`L`| 2 |
36
36
|`F`| 3 |
37
37
38
-
* We need to check that the file class match with the one we are supporting. There are two possible classes: 64 and 32. This is byte 4
39
-
* The data field indicates the _endiannes_, again this depends on the architecture used. It can be three values: None (0), LSB (1) and MSB (2). For example `x86_64` architecture endiannes is LSB, then the value is expected to be 1. This field is in the byte 5.
38
+
* We need to check that the file class match with the one we are supporting. There are two possible classes: _64_ and _32_. This is byte 4
39
+
* The data field indicates the _endiannes_, again this depends on the architecture used. It can be three values: **None (0)**, **LSB (1)** and **MSB (2)**. For example `x86_64` architecture endiannes is _LSB_, then the value is expected to be 1. This field is in the byte 5.
40
40
* The version field, byte 6, to be a valid elf it has to be set to 1 (EVCURRENT).
41
41
* The OS ABI and ABI version they identify the operating system together with the ABI to which the object is targeted and the version of the ABI to which the object is targeted, for now we can ignore them, the should be 0.
42
42
@@ -74,7 +74,7 @@ loop:
74
74
75
75
```
76
76
77
-
The code, as we can expect is pretty simple, and self-explanatory, it declares a `loop` function, and mark it as global using the `extern` keyword..
77
+
The code, as we can expect is pretty simple, and self-explanatory, it declares a `loop` function, and mark it as global using the `extern` keyword.
0 commit comments