Skip to content

Commit 47f73fc

Browse files
committed
Make opcode 0x00 unreachable. (#684)
Make opcode 0x00 `unreachable`, and move `nop` to a non-zero opcode. All-zeros is one of the more common patterns of corrupted data. This change makes it more likely that code that is accidentally zeroed, in whole or in part, will be noticed when executed rather than silently running through a nop slide. Obviously, this doesn't matter when an opcode table is present, but if there is a default opcode table, it would presumably use the opcodes defined here.
1 parent 754f5b9 commit 47f73fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

BinaryEncoding.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ It is legal to have several entries with the same type.
326326

327327
| Name | Opcode | Immediates | Description |
328328
| ---- | ---- | ---- | ---- |
329-
| `nop` | `0x00` | | no operation |
329+
| `unreachable` | `0x00` | | trap immediately |
330330
| `block` | `0x01` | | begin a sequence of expressions, the last of which yields a value |
331331
| `loop` | `0x02` | | begin a block which can also form control flow loops |
332332
| `if` | `0x03` | | begin if expression |
@@ -336,7 +336,7 @@ It is legal to have several entries with the same type.
336336
| `br_if` | `0x07` | argument_count : `varuint1`, relative_depth : `varuint32` | conditional break that targets an outer nested block |
337337
| `br_table` | `0x08` | see below | branch table control flow construct |
338338
| `return` | `0x09` | argument_count : `varuint1` | return zero or one value from this function |
339-
| `unreachable` | `0x0a` | | trap immediately |
339+
| `nop` | `0x0a` | | no operation |
340340
| `end` | `0x0f` | | end a block, loop, or if |
341341

342342
Note that there is no explicit `if_else` opcode, as the else clause is encoded with the `else` bytecode.

0 commit comments

Comments
 (0)