forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disallow control flow opcodes in
asm
blocks (FuelLabs#3279)
- Loading branch information
1 parent
d613be1
commit 7db4fed
Showing
8 changed files
with
142 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/src/e2e_vm_tests/test_programs/should_fail/asm_disallowed_opcodes/Forc.lock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[[package]] | ||
name = 'asm_disallowed_opcodes' | ||
source = 'member' |
6 changes: 6 additions & 0 deletions
6
test/src/e2e_vm_tests/test_programs/should_fail/asm_disallowed_opcodes/Forc.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[project] | ||
authors = ["Fuel Labs <[email protected]>"] | ||
entry = "main.sw" | ||
implicit-std = false | ||
license = "Apache-2.0" | ||
name = "asm_disallowed_opcodes" |
15 changes: 15 additions & 0 deletions
15
test/src/e2e_vm_tests/test_programs/should_fail/asm_disallowed_opcodes/src/main.sw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
script; | ||
|
||
fn main() -> u64 { | ||
asm(r1: 0, r2: 0, r3, r4) { | ||
jmp r1; | ||
ji i5; | ||
jne r1 r2 r3; | ||
jnei r1 r2 i5; | ||
jnzi r1 i5; | ||
ret r1; | ||
retd r1 r2; | ||
rvrt r1; | ||
}; | ||
0 | ||
} |
32 changes: 32 additions & 0 deletions
32
test/src/e2e_vm_tests/test_programs/should_fail/asm_disallowed_opcodes/test.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
category = "fail" | ||
|
||
# check: $()jmp r1 | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. | ||
# nextln: $()ji i5 | ||
|
||
# check: $()ji i5 | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. | ||
# nextln: $()jne r1 r2 r3; | ||
|
||
# check: $()jne r1 r2 r3; | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. | ||
# nextln: $()jnei r1 r2 i5; | ||
|
||
# check: $()jnei r1 r2 i5; | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. | ||
# nextln: $()jnzi r1 i5; | ||
|
||
# check: $()jnzi r1 i5; | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. | ||
# nextln: $()ret r1; | ||
|
||
# check: $()ret r1; | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. | ||
# nextln: $()retd r1 r2; | ||
|
||
# check: $()retd r1 r2; | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. | ||
# nextln: $()rvrt r1; | ||
|
||
# check: $()rvrt r1; | ||
# nextln: $()Control flow VM instructions are not allowed in assembly blocks. |