summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-12-19 18:36:09 -0800
committerBrian Anderson <banderson@mozilla.com>2011-12-19 18:47:39 -0800
commitedf6e1ec0e038b805a36a7e3689b37fc3cea7387 (patch)
treeb4fb1ef094fc68a8b1fc4c8aa31baf650b7f8ef7 /src/rt
parent586281e2d6d7f63e2b2d2b09c7f310f3b1d35355 (diff)
downloadrust-edf6e1ec0e038b805a36a7e3689b37fc3cea7387.tar.gz
rust-edf6e1ec0e038b805a36a7e3689b37fc3cea7387.zip
rt: Zero the bottom frame's return address and base pointer
My reading of libunwind leads me to believe this is expected.

Closes #1322
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/arch/i386/context.cpp6
-rw-r--r--src/rt/arch/x86_64/context.cpp6
2 files changed, 10 insertions, 2 deletions
diff --git a/src/rt/arch/i386/context.cpp b/src/rt/arch/i386/context.cpp
index f5fa3777eec..e65420dc0e3 100644
--- a/src/rt/arch/i386/context.cpp
+++ b/src/rt/arch/i386/context.cpp
@@ -31,10 +31,14 @@ void context::call(void *f, void *arg, void *stack) {
   // Shift the stack pointer so the alignment works out right.
   sp = align_down(sp) - 3;
   *--sp = (uint32_t)arg;
-  *--sp = 0xdeadbeef;
+  // The final return address. 0 indicates the bottom of the stack
+  *--sp = 0;
 
   regs.esp = (uint32_t)sp;
   regs.eip = (uint32_t)f;
+
+  // Last base pointer on the stack should be 0
+  regs.ebp = 0;
 }
 
 #if 0
diff --git a/src/rt/arch/x86_64/context.cpp b/src/rt/arch/x86_64/context.cpp
index d9070c6385a..46a606c6c6e 100644
--- a/src/rt/arch/x86_64/context.cpp
+++ b/src/rt/arch/x86_64/context.cpp
@@ -28,9 +28,13 @@ void context::call(void *f, void *arg, void *stack) {
   // set up the stack
   uint64_t *sp = (uint64_t *)stack;
   sp = align_down(sp);
-  *--sp = 0xdeadbeef; // takes place of ret. addr.
+  // The final return address. 0 indicates the bottom of the stack
+  *--sp = 0;
 
   regs.data[RUSTRT_ARG0] = (uint64_t)arg;
   regs.data[RUSTRT_RSP] = (uint64_t)sp;
   regs.data[RUSTRT_IP] = (uint64_t)f;
+
+  // Last base pointer on the stack should be 0
+  regs.data[RUSTRT_RBP] = 0;
 }