2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
8 * NaCl Simple/secure ELF loader (NaCl SEL).
10 #include "native_client/src/trusted/service_runtime/nacl_config.h"
11 #include "native_client/src/trusted/service_runtime/arch/x86_32/sel_rt_32.h"
14 * Assembly code template. This is linked into the service runtime
15 * but is unused as code -- it is used as data to be patched into
16 * a NaCl app's address space as a "hidden" part of its trampoline
21 * This is code, but it is not code that is actually part of the
22 * program/library being linked. Marking it as read-only data
23 * instead ensures that nothing like linker code-rewriting will
24 * be applied to this code.
29 * NaCl_springboard is used for syscall return and any time we want
30 * to do an upcall into NaCl application.
33 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_springboard):
35 /* Restore state from struct NaClThreadContext. */
36 /* syscall return value, if any, from trusted stack */
37 mov NACL_THREAD_CONTEXT_OFFSET_SYSRET(%ecx), %eax
38 lss NACL_THREAD_CONTEXT_OFFSET_STACK_PTR(%ecx), %esp
39 movw NACL_THREAD_CONTEXT_OFFSET_DS(%ecx), %ds
40 /* Set %ecx to zero to avoid leaking the NaClThreadContext address. */
43 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_springboard_end):
46 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_springboard_all_regs):
48 /* Restore state from struct NaClSwitchRemainingRegsState. */
49 lss 0(%ecx), %esp /* stack_ptr */
50 movw 0x10(%ecx), %ds /* ds */
51 movl %gs:0xc, %ecx /* new_ecx from NaClGsSegment */
52 jmp *%gs:8 /* new_prog_ctr from NaClGsSegment */
53 DEFINE_GLOBAL_HIDDEN_LOCATION(NaCl_springboard_all_regs_end):