rt: Move the addition of the stack canary into create_stack

This commit is contained in:
Brian Anderson
2012-02-10 11:24:44 -08:00
parent 5fc2e9e9ab
commit fc028c30a0
2 changed files with 4 additions and 4 deletions

View File

@@ -13,12 +13,16 @@ struct stk_seg {
uint8_t data[]; uint8_t data[];
}; };
void
add_stack_canary(stk_seg *stk);
template <class T> template <class T>
stk_seg * stk_seg *
create_stack(T allocer, size_t sz) { create_stack(T allocer, size_t sz) {
size_t total_sz = sizeof(stk_seg) + sz; size_t total_sz = sizeof(stk_seg) + sz;
stk_seg *stk = (stk_seg *)allocer->malloc(total_sz, "stack"); stk_seg *stk = (stk_seg *)allocer->malloc(total_sz, "stack");
memset(stk, 0, sizeof(stk_seg)); memset(stk, 0, sizeof(stk_seg));
add_stack_canary(stk);
stk->end = (uintptr_t) &stk->data[sz]; stk->end = (uintptr_t) &stk->data[sz];
return stk; return stk;
} }
@@ -35,9 +39,6 @@ config_valgrind_stack(stk_seg *stk);
void void
unconfig_valgrind_stack(stk_seg *stk); unconfig_valgrind_stack(stk_seg *stk);
void
add_stack_canary(stk_seg *stk);
void void
check_stack_canary(stk_seg *stk); check_stack_canary(stk_seg *stk);

View File

@@ -593,7 +593,6 @@ rust_task::new_stack(size_t requested_sz) {
size_t sz = rust_stk_sz + RED_ZONE_SIZE; size_t sz = rust_stk_sz + RED_ZONE_SIZE;
stk_seg *new_stk = create_stack(this, sz); stk_seg *new_stk = create_stack(this, sz);
LOGPTR(thread, "new stk", (uintptr_t)new_stk); LOGPTR(thread, "new stk", (uintptr_t)new_stk);
add_stack_canary(new_stk);
new_stk->prev = NULL; new_stk->prev = NULL;
new_stk->next = stk; new_stk->next = stk;
LOGPTR(thread, "stk end", new_stk->end); LOGPTR(thread, "stk end", new_stk->end);