Align the child stack in clone(2).

Also let clone(2) set the TLS for x86.

Also ensure we initialize the TLS before we clone(2) for all architectures.

Change-Id: Ie5fa4466e1c9ee116a281dfedef574c5ba60c0b5
This commit is contained in:
Elliott Hughes
2014-05-09 14:42:16 -07:00
parent 8fa5c2528c
commit 0d236aa3f1
7 changed files with 61 additions and 94 deletions

View File

@@ -59,5 +59,10 @@ int clone(int (*fn)(void*), void* child_stack, int flags, void* arg, ...) {
}
va_end(args);
// Align 'child_stack' to 16 bytes.
uintptr_t child_stack_addr = reinterpret_cast<uintptr_t>(child_stack);
child_stack_addr &= ~0xf;
child_stack = reinterpret_cast<void*>(child_stack_addr);
return __bionic_clone(flags, child_stack, parent_tid, new_tls, child_tid, fn, arg);
}