Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Unified Diff: src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S

Issue 7276050: Change startup ABI for untrusted code to be C-compatible (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: disable bogus stack_frame.cc test for now Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
diff --git a/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S b/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
index 7f83707fc5d557be2c8118799bae6c5aaf3f2b42..ce425b20d67ee769fa622a224b52b1d711169081 100644
--- a/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
+++ b/src/trusted/service_runtime/arch/x86_64/nacl_switch_64.S
@@ -1,7 +1,7 @@
/*
- * Copyright 2009 The Native Client Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can
- * be found in the LICENSE file.
+ * Copyright (c) 2011 The Native Client Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
*/
/*
@@ -23,25 +23,48 @@
IDENTIFIER(NaClSwitch):
#if NACL_WINDOWS
/* if Windows, 1st param is already in %rcx, not %rdi */
- mov %rcx, %rdi
#elif NACL_LINUX || NACL_OSX
/* elif Linux/OSX, 1st param is already in %rdi. */
+ mov %rdi, %rcx
#else
# error "What OS/compiler is the service runtime being compiled with?"
#endif
- movq 0x8(%rdi), %rbx
- movq 0x20(%rdi), %rbp
- movq 0x60(%rdi), %r12
- movq 0x68(%rdi), %r13
- movq 0x70(%rdi), %r14
- movq 0x78(%rdi), %r15
+ movq 0x8(%rcx), %rbx
+ movq 0x20(%rcx), %rbp
+ movq 0x60(%rcx), %r12
+ movq 0x68(%rcx), %r13
+ movq 0x70(%rcx), %r14
+ movq 0x78(%rcx), %r15
/* there is no springboard for x86_64 */
- movq 0x38(%rdi), %rsp /* rsp -- switch stack */
- movq 0x90(%rdi), %rax /* syscall return */
- jmp *0x88(%rdi)
+ movq 0x38(%rcx), %rsp /* rsp -- switch stack */
+ movq 0x90(%rcx), %rax /* syscall return */
+
+ /*
+ * %rdi is the first argument in the user calling convention.
+ * When starting the initial thread, we are passing the address
+ * of the parameter block here. The initial stack pointer has
+ * been adjusted to one word below there, to insert a dummy
+ * return address for the user entry point function.
+ */
+ leal 8(%rsp), %edi
+
+ /*
+ * Zero all unused registers. The 32-bit instructions
+ * are a byte shorter than their 64-bit counterparts
+ * when the target register is one of the first eight,
+ * and they implicitly zero the high halves.
+ */
+ xorl %edx, %edx
+ movl %edx, %esi
+ movq %rdx, %r8
+ movq %rdx, %r9
+ movq %rdx, %r10
+ movq %rdx, %r11
+
+ jmp *0x88(%rcx)
/*
- * This leaves %rdi pointing to the thread context, but that
+ * This leaves %rcx pointing to the thread context, but that
* should be memory that's inaccessible by NaCl module code.
*/
« no previous file with comments | « src/trusted/service_runtime/arch/arm/nacl_switch_to_app_arm.c ('k') | src/trusted/service_runtime/nacl_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698