Skip to content

Commit

Permalink
fix: Use correct index as shadowstack slot key (AssemblyScript#2720)
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrCai0907 committed Aug 1, 2023
1 parent c49823e commit 0ede7ff
Show file tree
Hide file tree
Showing 41 changed files with 6,440 additions and 2,245 deletions.
2 changes: 1 addition & 1 deletion src/passes/shadowstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ export class ShadowStackPass extends Pass {
}
let currentFunction = this.currentFunction;
let numLocals = _BinaryenFunctionGetNumLocals(currentFunction);
let slotIndex = this.noteSlot(currentFunction, numLocals + this.callSlotOffset + i);
let slotIndex = this.noteSlot(currentFunction, numLocals + this.callSlotOffset + numSlots);
let temp = this.getSharedTemp(currentFunction, this.ptrType);
let stmts = new Array<ExpressionRef>();
// t = value
Expand Down
14 changes: 7 additions & 7 deletions tests/compiler/bindings/esm.debug.wat
Original file line number Diff line number Diff line change
Expand Up @@ -4944,16 +4944,16 @@
(local $i|4 i32)
(local $5 i32)
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.sub
global.set $~lib/memory/__stack_pointer
call $~stack_check
global.get $~lib/memory/__stack_pointer
i64.const 0
i64.store $0
global.get $~lib/memory/__stack_pointer
i32.const 0
i32.store $0 offset=8
i64.const 0
i64.store $0 offset=8
global.get $~lib/memory/__stack_pointer
i32.const 0
local.get $a
Expand Down Expand Up @@ -4998,7 +4998,7 @@
local.set $5
global.get $~lib/memory/__stack_pointer
local.get $5
i32.store $0 offset=8
i32.store $0 offset=12
local.get $5
local.get $i
call $~lib/array/Array<~lib/string/String>#__get
Expand Down Expand Up @@ -5038,7 +5038,7 @@
local.set $5
global.get $~lib/memory/__stack_pointer
local.get $5
i32.store $0 offset=8
i32.store $0 offset=12
local.get $5
call $~lib/array/Array<~lib/string/String>#get:length
local.get $i|4
Expand All @@ -5047,7 +5047,7 @@
local.set $5
global.get $~lib/memory/__stack_pointer
local.get $5
i32.store $0 offset=8
i32.store $0 offset=12
local.get $5
local.get $i|4
call $~lib/array/Array<~lib/string/String>#__get
Expand All @@ -5067,7 +5067,7 @@
local.get $c
local.set $5
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.add
global.set $~lib/memory/__stack_pointer
local.get $5
Expand Down
14 changes: 7 additions & 7 deletions tests/compiler/bindings/esm.release.wat
Original file line number Diff line number Diff line change
Expand Up @@ -3459,7 +3459,7 @@
(local $7 i32)
(local $8 i32)
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.sub
global.set $~lib/memory/__stack_pointer
block $folding-inner0
Expand All @@ -3472,8 +3472,8 @@
i64.const 0
i64.store $0
local.get $3
i32.const 0
i32.store $0 offset=8
i64.const 0
i64.store $0 offset=8
local.get $3
local.get $0
i32.store $0
Expand Down Expand Up @@ -3616,7 +3616,7 @@
i32.store $0
local.get $3
local.get $0
i32.store $0 offset=8
i32.store $0 offset=12
local.get $0
local.get $2
call $~lib/array/Array<~lib/string/String>#__get
Expand Down Expand Up @@ -3652,15 +3652,15 @@
i32.store $0
local.get $3
local.get $0
i32.store $0 offset=8
i32.store $0 offset=12
local.get $0
call $~lib/array/Array<i32>#get:length
local.get $2
i32.add
local.set $3
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store $0 offset=8
i32.store $0 offset=12
local.get $1
local.get $2
call $~lib/array/Array<~lib/string/String>#__get
Expand All @@ -3680,7 +3680,7 @@
end
end
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.add
global.set $~lib/memory/__stack_pointer
local.get $5
Expand Down
14 changes: 7 additions & 7 deletions tests/compiler/bindings/raw.debug.wat
Original file line number Diff line number Diff line change
Expand Up @@ -4947,16 +4947,16 @@
(local $i|4 i32)
(local $5 i32)
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.sub
global.set $~lib/memory/__stack_pointer
call $~stack_check
global.get $~lib/memory/__stack_pointer
i64.const 0
i64.store $0
global.get $~lib/memory/__stack_pointer
i32.const 0
i32.store $0 offset=8
i64.const 0
i64.store $0 offset=8
global.get $~lib/memory/__stack_pointer
i32.const 0
local.get $a
Expand Down Expand Up @@ -5001,7 +5001,7 @@
local.set $5
global.get $~lib/memory/__stack_pointer
local.get $5
i32.store $0 offset=8
i32.store $0 offset=12
local.get $5
local.get $i
call $~lib/array/Array<~lib/string/String>#__get
Expand Down Expand Up @@ -5041,7 +5041,7 @@
local.set $5
global.get $~lib/memory/__stack_pointer
local.get $5
i32.store $0 offset=8
i32.store $0 offset=12
local.get $5
call $~lib/array/Array<~lib/string/String>#get:length
local.get $i|4
Expand All @@ -5050,7 +5050,7 @@
local.set $5
global.get $~lib/memory/__stack_pointer
local.get $5
i32.store $0 offset=8
i32.store $0 offset=12
local.get $5
local.get $i|4
call $~lib/array/Array<~lib/string/String>#__get
Expand All @@ -5070,7 +5070,7 @@
local.get $c
local.set $5
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.add
global.set $~lib/memory/__stack_pointer
local.get $5
Expand Down
14 changes: 7 additions & 7 deletions tests/compiler/bindings/raw.release.wat
Original file line number Diff line number Diff line change
Expand Up @@ -3459,7 +3459,7 @@
(local $7 i32)
(local $8 i32)
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.sub
global.set $~lib/memory/__stack_pointer
block $folding-inner0
Expand All @@ -3472,8 +3472,8 @@
i64.const 0
i64.store $0
local.get $3
i32.const 0
i32.store $0 offset=8
i64.const 0
i64.store $0 offset=8
local.get $3
local.get $0
i32.store $0
Expand Down Expand Up @@ -3616,7 +3616,7 @@
i32.store $0
local.get $3
local.get $0
i32.store $0 offset=8
i32.store $0 offset=12
local.get $0
local.get $2
call $~lib/array/Array<~lib/string/String>#__get
Expand Down Expand Up @@ -3652,15 +3652,15 @@
i32.store $0
local.get $3
local.get $0
i32.store $0 offset=8
i32.store $0 offset=12
local.get $0
call $~lib/array/Array<i32>#get:length
local.get $2
i32.add
local.set $3
global.get $~lib/memory/__stack_pointer
local.get $1
i32.store $0 offset=8
i32.store $0 offset=12
local.get $1
local.get $2
call $~lib/array/Array<~lib/string/String>#__get
Expand All @@ -3680,7 +3680,7 @@
end
end
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.const 16
i32.add
global.set $~lib/memory/__stack_pointer
local.get $5
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/duplicate-fields.debug.wat
Original file line number Diff line number Diff line change
Expand Up @@ -2957,7 +2957,7 @@
local.set $0
global.get $~lib/memory/__stack_pointer
local.get $0
i32.store $0 offset=4
i32.store $0
local.get $0
call $duplicate-fields/B2#constructor
global.set $duplicate-fields/raz
Expand Down
2 changes: 1 addition & 1 deletion tests/compiler/duplicate-fields.release.wat
Original file line number Diff line number Diff line change
Expand Up @@ -1818,7 +1818,7 @@
global.set $~lib/memory/__stack_pointer
global.get $~lib/memory/__stack_pointer
local.get $2
i32.store $0 offset=4
i32.store $0
global.get $~lib/memory/__stack_pointer
i32.const 12
i32.sub
Expand Down
Loading

0 comments on commit 0ede7ff

Please sign in to comment.