Skip to content

Commit d6b680d

Browse files
committed
ssamoswap is treated as an invalid instruction when ss is not active
1 parent b700f63 commit d6b680d

File tree

7 files changed

+26
-7
lines changed

7 files changed

+26
-7
lines changed

src/instructions/cfi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn factory<R: Register>(
4141
}
4242
insts::OP_SSAMOSWAP_W | insts::OP_SSAMOSWAP_D => {
4343
if !cfi.ss {
44-
return Some(set_instruction_length_4(nop()));
44+
return None;
4545
}
4646
return Some(i);
4747
}

tests/programs/_build_cfi_native.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build() {
1515

1616
build cfi_ss_success.S cfi_ss_success
1717
build cfi_ss_not_active.S cfi_ss_not_active
18+
build cfi_ss_not_active_amo.S cfi_ss_not_active_amo
1819
build cfi_ss_stack_downto_zero.S cfi_ss_stack_downto_zero
1920
build cfi_ss_stack_full.S cfi_ss_stack_full
2021
build cfi_lpad_unlabeled.S cfi_lpad_unlabeled
@@ -26,4 +27,3 @@ build cfi_lpad_func_sig_failed.S cfi_lpad_func_sig_failed
2627
build cfi_ss_only_pop.S cfi_ss_only_pop
2728
build cfi_ss_popchk_failed.S cfi_ss_popchk_failed
2829
build cfi_lpad_align_failed.S cfi_lpad_align_failed
29-

tests/programs/cfi_ss_not_active

-8 Bytes
Binary file not shown.

tests/programs/cfi_ss_not_active.S

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ _start:
1616
ssrdp t0
1717
beqz t0, 1f
1818
exit_imm 1
19-
19+
2020
1:
21-
// ssamoswap works as May-Be-Operations? TODO
22-
li t0, -1
23-
ssamoswap.d ra, x0, (t0)
24-
exit_imm 0
21+
exit_imm 0
848 Bytes
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.include "cfi_macro.h"
2+
3+
gnu_property_cfi_ss 0
4+
5+
.text
6+
.global _start
7+
_start:
8+
li t0, -1
9+
ssamoswap.d ra, x0, (t0)
10+
exit_imm 0

tests/test_cfi.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ pub fn test_cfi_ss_not_active() {
3636
assert_eq!(ret, Ok(0));
3737
}
3838

39+
#[test]
40+
pub fn test_cfi_ss_not_active_amo() {
41+
let ret = run("tests/programs/cfi_ss_not_active_amo");
42+
assert!(matches!(
43+
ret,
44+
Err(Error::InvalidInstruction {
45+
pc: 69922,
46+
instruction: 1208135855
47+
})
48+
));
49+
}
50+
3951
#[test]
4052
pub fn test_cfi_ss_stack_downto_zero() {
4153
let ret = run("tests/programs/cfi_ss_stack_downto_zero");

0 commit comments

Comments
 (0)