OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2012 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can |
| 4 * be found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 #include "native_client/src/trusted/service_runtime/nacl_config.h" |
| 8 |
| 9 .text |
| 10 |
| 11 /* |
| 12 * Assembly code template. |
| 13 * This is linked into the service runtime but is unused as code -- it is used |
| 14 * as data to be patched into a NaCl app's address space. |
| 15 * |
| 16 * Trampoline to transfer control from native client module to |
| 17 * sel_ldr's NaClSyscallSeg residing in the service runtime portion of address |
| 18 * space. Trampolines are patched into nacl module's address space in the |
| 19 * trampoline region. They are patched by NaClLoadTrampoline() code (sel_ldr.c). |
| 20 * Each trampoline code segment corresponds to a system call, so the trampoline |
| 21 * region is full of identical trampoline code segments. Service runtime |
| 22 * distinguish which system call is requested using the address of an executed |
| 23 * trampoline (it is saved on stack in NaClSyscallSeg()). |
| 24 * |
| 25 * The trampoline code should push first 4 parameters of the system call to |
| 26 * the stack, and on top of that it should push the return address. On Mips the |
| 27 * trampoline is too small for all this, so the only thing that trampoline does |
| 28 * is call the function NaClSyscallSeg where the push is actually done. |
| 29 */ |
| 30 |
| 31 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaCl_trampoline_seg_code): |
| 32 |
| 33 .set noreorder |
| 34 |
| 35 /* |
| 36 * We don't actually load $t9 with zero, but we patch it with real address |
| 37 * of NaClSyscallSeg during placement of trampoline code. |
| 38 */ |
| 39 |
| 40 lui $t9, 0 |
| 41 ori $t9, $t9, 0 |
| 42 jalr $t5, $t9 |
| 43 nop |
| 44 |
| 45 jr $0 /* NACL_HALT - at the start of the second block of the trampoline */ |
| 46 .set reorder |
| 47 |
| 48 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaCl_trampoline_seg_end): |
| 49 |
OLD | NEW |