@@ -1023,12 +1023,12 @@ The `JUMP*` family of operations affect the current program counter.
1023
1023
// ---------------------------
1024
1024
rule <k> JUMP DEST => #endBasicBlock... </k>
1025
1025
<pc> _ => DEST </pc>
1026
- <jumpDests> DESTS </jumpDests >
1027
- requires DEST in DESTS
1026
+ <program> PGM </program >
1027
+ requires #isValidJumpDest(PGM, DEST)
1028
1028
1029
1029
rule <k> JUMP DEST => #end EVMC_BAD_JUMP_DESTINATION ... </k>
1030
- <jumpDests> DESTS </jumpDests >
1031
- requires notBool DEST in DESTS
1030
+ <program> PGM </program >
1031
+ requires notBool #isValidJumpDest(PGM, DEST)
1032
1032
1033
1033
syntax BinStackOp ::= "JUMPI"
1034
1034
// -----------------------------
@@ -1306,7 +1306,6 @@ The various `CALL*` (and other inter-contract control flow) operations will be d
1306
1306
// -------------------------------------
1307
1307
rule <k> #loadProgram BYTES => . ... </k>
1308
1308
<program> _ => BYTES </program>
1309
- <jumpDests> _ => #computeValidJumpDests(BYTES) </jumpDests>
1310
1309
1311
1310
syntax KItem ::= "#touchAccounts" Account | "#touchAccounts" Account Account
1312
1311
// ----------------------------------------------------------------------------
@@ -1341,15 +1340,21 @@ The various `CALL*` (and other inter-contract control flow) operations will be d
1341
1340
syntax Set ::= #computeValidJumpDests(Bytes) [function, memo, total]
1342
1341
| #computeValidJumpDests(Bytes, Int, List) [function, klabel(#computeValidJumpDestsAux)]
1343
1342
// -----------------------------------------------------------------------------------------------------
1344
- rule #computeValidJumpDests(PGM) => #computeValidJumpDests(PGM, 0, .List)
1343
+ rule #computeValidJumpDests(PGM) => .Set
1344
+ rule #computeValidJumpDests(PGM, I, RESULT) => .Set
1345
+
1345
1346
1346
1347
syntax Set ::= #computeValidJumpDestsWithinBound(Bytes, Int, List) [function]
1347
1348
// -----------------------------------------------------------------------------
1348
- rule #computeValidJumpDests(PGM, I, RESULT) => List2Set(RESULT) requires I >=Int lengthBytes(PGM)
1349
- rule #computeValidJumpDests(PGM, I, RESULT) => #computeValidJumpDestsWithinBound(PGM, I, RESULT) requires I <Int lengthBytes(PGM)
1349
+ rule #computeValidJumpDestsWithinBound(PGM, I, RESULT) => .Set
1350
+
1351
+
1352
+ syntax Bool ::= #isValidJumpDest ( Bytes, Int ) [function, total]
1353
+
1354
+ rule #isValidJumpDest(PGM, I) => PGM [ I ] ==Int 91 requires 0 <=Int I andBool I <Int lengthBytes(PGM)
1355
+ rule #isValidJumpDest(PGM, I) => false [owise]
1350
1356
1351
- rule #computeValidJumpDestsWithinBound(PGM, I, RESULT) => #computeValidJumpDests(PGM, I +Int 1, RESULT ListItem(I)) requires PGM [ I ] ==Int 91
1352
- rule #computeValidJumpDestsWithinBound(PGM, I, RESULT) => #computeValidJumpDests(PGM, I +Int #widthOpCode(PGM [ I ]), RESULT) requires notBool PGM [ I ] ==Int 91
1357
+ rule
1353
1358
```
1354
1359
1355
1360
``` k
0 commit comments