Skip to content

Commit

Permalink
Greatly expand errata
Browse files Browse the repository at this point in the history
  • Loading branch information
sayon committed Dec 10, 2017
1 parent 6a1cbfe commit ecb0987
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 4 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,11 @@ Release v1.0 corresponds to the code in the published book, without corrections

## Contributions

See the file Contributing.md for more information on how you can contribute to this repository.
See the file Contributing.md for more information on how you can contribute to
this repository.

I want to personally thank Kunio Yoshikawa for his amazing and most
effective contributions in finding errors and typos in the book.

I also thank all readers who have provided me with feedback, critique and
corrections. Your work benefits the community!
127 changes: 127 additions & 0 deletions errata.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ there.

"...while main memory uses ~~condensers~~ capacitors"

### Page 10, Section 1.3.1

"The smallest parts ~~pf~~ of rsp"

### Page 35, Section 2.7.

* `read_word` should also return word length in `rdx` when the value
Expand All @@ -29,10 +33,19 @@ there.
" Their codes are 0x20, 0x9, and ~~0x10~~ 0xA, respectively."


### Page 37, Section 1.3.2
"Figure 1-3. Approximation of Intel 64: general purpose registers"

To prevent confusion: `rip` and `rflags` are not general purpose registers, although they are shown on this figure. The name should be "general purpose registers, `rip` and `rflags`".

### Page 45, Section 3.4.1.

"...fills the upper half of a wide register with ~~sign bit~~zero bits!"

### Page 45, Section 3.4.2.

CISC (~~Complete~~ Complex Instruction Set Computer)

### Page 57, Section 4.9.

"~~Use `print_string` routine...~~": the entire list item should be removed.
Expand All @@ -41,10 +54,124 @@ there.

"... will also accept ~~`rip` and~~ `rflags` register~~s~~."

### Page 69, Section 5.1.6.

"In case the argument is neither ~~string~~ number nor identifier,"

### Page 71, Section 5.1.9.

"For each ~~_current_~~ _n_ up to _limit_"

### Page 73, Section 5.1.10

In Listing 5-19, "Mymacro" should be substituted with "mymacro".

### Page 83, Listing 5-31

The `-shared` flag should be used when creating `libso.so` (third line), not
the executable. Corrected listing:
[listings/chap5/libso/libso](listings/chap5/libso/libso)

### Page 92, Section 6.1

"Thus, setting IOPL in an application individually allows us to forbid it from writing even if it is working
at a higher privilege level than the user applications."

TODO clarify

"If the IOPL check has passed, the processor checks the bit corresponding to the used port. The operation proceeds only if this bit is not set."

Clarification:

There are two checks when a CPU tries to execute an instruction that works
with I/O ports such as `in` or `out`.

1. The I/O privilege level check is performed to see, whether the application
has a right to access any ports at all.

This is done based on two special bits in `rflags` register. They encode a
privilege level of the task, called IOPL. This two-bit number is compared to
the task's CPL (stored in `cs` register).

If CPL > IOPL, the program has not enough privileges to access I/O ports at all.

Otherwise, a second check is performed:

2.The I/O permission map is used to determine, whether we can access a specific
port or not (bit set to 1 means "forbidden").

### Pate 98, Section 6.3.2

Code segment shadow register:

* "Type = 11_~~2~~" -- this is not a binary 11, but a decimal one.

11 (dec) = 1011 (binary)

### Pate 99, Section 6.3.2

Same typo:

Stack segment shadow register:

* "Type = 11_~~2~~" -- this is not a binary 11, but a decimal one.

11 (dec) = 1011 (binary)

### Page 108, Section 7.1.5
" * This way we handle ^ and ..."

This line should not be an isolated element of the bulleted list, but rather a part of
a previous one.

### Page 113, Section 7.2.4

Figure 7-10: the "Dictionary Entry" block lacks 'flags' after 'dup0'.

Should be:

| link | d | u | p | 0 | flags | dup_impl |

### Page 118, Section 7.3

"...guaranteed to survive function calls unchanged (~~caller-saved~~__callee-saved__): r13, r14, or r15."

### Page 124, Section

* `0branch <offset>` ~~Branch~~ `0branch` is a compile-only word. Jump to a location if TOS = 0.

Both `0branch` and `branch` are compile-only.

### Page 137, Section 8.3.5

Then, as the break is not ending this case, after executing the first
~~`printf`~~ `puts` the control will fall to the next instruction labeled case
15, another ~~`printf`~~ `puts`.

### Page 141, Section 8.4.2.

"3. as ..." should be "3. * as ..."

### Page 171, Section 9.2.4

"... similar to how ~~DEFINE~~ `#define` works"

### Page 175, Section 9.4.1

Listing 9-54: the comment should be between `/*` and `*/`, but it is not closed
(lacks `*/`).

Corrected listing: [listings/chap9/macro_str/macro_str.c](listings/chap9/macro_str/macro_str.c).

### Page 189, Section 10.3

Listing 10-25 is not properly indented.


Corrected listing: [listings/chap10/ldd_locating_libc/ldd_locating_libc](listings/chap10/ldd_locating_libc/ldd_locating_libc).



### Page 257, Section 13.10.1.

In the listing `bmp_struct.c`, `struct` keyword should start with a lower case letter.
Expand Down
4 changes: 2 additions & 2 deletions listings/chap10/ldd_locating_libc/ldd_locating_libc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
> gcc main.c -o main
> ldd main
> gcc main.c -o main
> ldd main
linux-vdso.so.1 (0x00007fff4e7fc000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2b7f6bf000)
/lib64/ld-linux-x86-64.so.2 (0x00007f2b7fa76000)
2 changes: 1 addition & 1 deletion listings/chap9/macro_str/macro_str.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define mystr hello
#define res #mystr

puts( res ); /* will be replaced with `puts("hello")`
puts( res ); /* will be replaced with `puts("hello")` */

0 comments on commit ecb0987

Please sign in to comment.