summaryrefslogtreecommitdiff
path: root/notes.txt
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2011-12-06 16:13:18 +0000
committerPeter Wu <lekensteyn@gmail.com>2011-12-06 16:13:18 +0000
commit6e8c92a69c6f7abe88d98e729e06bca6ccf17d72 (patch)
tree2b3ecc0db0e2b020fabdd5c8ba628615cf4080ea /notes.txt
parent96333bbb306f7141dee99dc01a9afff8bc7b114b (diff)
downloadpp2cc-6e8c92a69c6f7abe88d98e729e06bca6ccf17d72.tar.gz
Fix stack corruption when using arguments (param access off by one)
Diffstat (limited to 'notes.txt')
-rw-r--r--notes.txt5
1 files changed, 3 insertions, 2 deletions
diff --git a/notes.txt b/notes.txt
index d2998c1..5d8bbe0 100644
--- a/notes.txt
+++ b/notes.txt
@@ -26,7 +26,8 @@ Caller:
Callee:
1. push R5 (base pointer "BP" in stack for local variables and parameters)
2. Store current stack pointer in R5 (LOAD R5 SP). [R5] now contains the return
- address, [R5+i] the i-th parameter and [R5+-i] the i-th local var
+ address, [R5+i+1] the i-th parameter and [R5+-i] the i-th local var. Param i
+ is at R5 + i + 1 because BP was pushed too
3. Grow stack for local variables (by SUB SP n) if necessary
4. <function body>
5. LOAD SP R5 (clear local vars)
@@ -34,7 +35,7 @@ Callee:
6. RTS (go back to caller)
parameter access (i-th parameter):
-LOAD R0 [R5+i]
+LOAD R0 [R5+i+1]
local variable access (i-th local var)
LOAD R0 [R5+-i]
global variable access