about summary refs log tree commit diff
path: root/src/rt/rust_stack.cpp
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-02-15 15:41:59 -0800
committerBrian Anderson <banderson@mozilla.com>2012-02-17 11:37:17 -0800
commit853e2003b8383749596e5b7b153186e2eef32455 (patch)
treed40153901e6b2bc8c8448f7a1c58adb440c8d385 /src/rt/rust_stack.cpp
parent2796ab6de9eefb3d009a410e45f5c154469c94b7 (diff)
downloadrust-853e2003b8383749596e5b7b153186e2eef32455.tar.gz
rust-853e2003b8383749596e5b7b153186e2eef32455.zip
rt: Make the stack canary just a word on the stk_seg struct
Diffstat (limited to 'src/rt/rust_stack.cpp')
-rw-r--r--src/rt/rust_stack.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/rt/rust_stack.cpp b/src/rt/rust_stack.cpp
index 84e4215ac67..37acc438672 100644
--- a/src/rt/rust_stack.cpp
+++ b/src/rt/rust_stack.cpp
@@ -3,6 +3,12 @@
 #include "vg/valgrind.h"
 #include "vg/memcheck.h"
 
+#ifdef _LP64
+const uintptr_t canary_value = 0xABCDABCDABCDABCD;
+#else
+const uintptr_t canary_value = 0xABCDABCD;
+#endif
+
 void
 register_valgrind_stack(stk_seg *stk) {
     stk->valgrind_id =
@@ -17,8 +23,7 @@ prepare_valgrind_stack(stk_seg *stk) {
     // old stack segments, since the act of popping the stack previously
     // caused valgrind to consider the whole thing inaccessible.
     size_t sz = stk->end - (uintptr_t)&stk->data[0];
-    VALGRIND_MAKE_MEM_UNDEFINED(stk->data + sizeof(stack_canary),
-                                sz - sizeof(stack_canary));
+    VALGRIND_MAKE_MEM_UNDEFINED(stk->data, sz);
 #endif
 }
 
@@ -29,12 +34,10 @@ deregister_valgrind_stack(stk_seg *stk) {
 
 void
 add_stack_canary(stk_seg *stk) {
-    memcpy(stk->data, stack_canary, sizeof(stack_canary));
-    assert(sizeof(stack_canary) == 16 && "Stack canary was not the expected size");
+    stk->canary = canary_value;
 }
 
 void
 check_stack_canary(stk_seg *stk) {
-    assert(!memcmp(stk->data, stack_canary, sizeof(stack_canary))
-      && "Somebody killed the canary");
+    assert(stk->canary == canary_value && "Somebody killed the canary");
 }