Merge "Fix 16-byte stack alignment requirement for x86_64 ABI"

This commit is contained in:
Elliott Hughes 2013-10-22 00:38:36 +00:00 committed by Gerrit Code Review
commit 9d4b67ea16
2 changed files with 9 additions and 4 deletions

View File

@ -50,6 +50,10 @@ void _start() {
array.fini_array = &__FINI_ARRAY__; array.fini_array = &__FINI_ARRAY__;
void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*)); void* raw_args = (void*) ((uintptr_t) __builtin_frame_address(0) + sizeof(void*));
#ifdef __x86_64__
// 16-byte stack alignment is required by x86_64 ABI
asm("andq $~15, %rsp");
#endif
__libc_init(raw_args, NULL, &main, &array); __libc_init(raw_args, NULL, &main, &array);
} }

View File

@ -59,10 +59,11 @@ ENTRY(__pthread_clone)
# We're in the child now, so call __thread_entry # We're in the child now, so call __thread_entry
# with the arguments from the child stack moved into # with the arguments from the child stack moved into
# the appropriate registers. # the appropriate registers. We avoid pop here to keep
popq %rdi # fn # the required 16-byte stack alignment.
popq %rsi # arg movq (%rsp), %rdi # fn
popq %rdx # tls movq 8(%rsp), %rsi # arg
movq 16(%rsp), %rdx # tls
call __thread_entry call __thread_entry
hlt hlt
2: 2: