OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "native_client/src/trusted/service_runtime/nacl_config.h" | 7 #include "native_client/src/trusted/service_runtime/nacl_config.h" |
8 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h
" | 8 #include "native_client/src/trusted/service_runtime/include/bits/nacl_syscalls.h
" |
9 | 9 |
10 .text | 10 .text |
11 .thumb | 11 .thumb |
12 .syntax unified | 12 .syntax unified |
13 | 13 |
| 14 /* |
| 15 * NOTE: it is not clear whether we need a spring board for ARM at all |
| 16 * TODO(robertm): maybe delete the code |
| 17 * |
| 18 * Assembly code template. |
| 19 * This is linked into the service runtime but is unused as code -- it is used |
| 20 * as data to be patched into a NaCl app's address space as a "hidden" part of |
| 21 * its trampoline region. |
| 22 * |
| 23 * This code takes the last slot in trampoline region, and it is |
| 24 * loaded by NaClLoadSpringboard() (sel_ldr.c). |
| 25 * |
| 26 * NaCl_springboard is used for syscall return and any time we want |
| 27 * to do an upcall into NaCl application. |
| 28 * |
| 29 * r0 -- syscall return value |
| 30 * r1 -- new pc (already sandboxed) |
| 31 * == user stack == |
| 32 * top |
| 33 * ===== |
| 34 * arg 1 |
| 35 * arg 2 |
| 36 * ..... |
| 37 * arg N |
| 38 */ |
| 39 |
14 /* | 40 /* |
15 * NOTE: it is not clear whether we need a spring board for ARM at all | 41 * We will load the springboard to be aligned 14mod16, as a thumb2 branch |
16 * TODO(robertm): maybe delete the code | 42 * target must be. To ensure that the instructions in the springboard are |
17 * | 43 * properly aligned, we misalign by 2 here. |
18 * Assembly code template. | |
19 * This is linked into the service runtime but is unused as code -- it is used | |
20 * as data to be patched into a NaCl app's address space as a "hidden" part of | |
21 * its trampoline region. | |
22 * | |
23 * This code takes the last slot in trampoline region, and it is | |
24 * loaded by NaClLoadSpringboard() (sel_ldr.c). | |
25 * | |
26 * NaCl_springboard is used for syscall return and any time we want | |
27 * to do an upcall into NaCl application. | |
28 * | |
29 * r0 -- syscall return value | |
30 * r1 -- new pc (already sandboxed) | |
31 * == user stack == | |
32 * top | |
33 * ===== | |
34 * arg 1 | |
35 * arg 2 | |
36 * ..... | |
37 * arg N | |
38 */ | 44 */ |
39 | |
40 /* | |
41 * We will load the springboard to be aligned 14mod16, as a thumb2 branch | |
42 * target must be. To ensure that the instructions in the springboard are | |
43 * properly aligned, we misalign by 2 here. | |
44 */ | |
45 .p2align 4 | 45 .p2align 4 |
46 .skip 2 | 46 .skip 2 |
47 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaCl_springboard): | 47 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaCl_springboard): |
48 /* | 48 /* |
49 * This instruction prevents indirect jumps from untrusted code into the | 49 * This instruction prevents indirect jumps from untrusted code into the |
50 * springboard. The service runtime jumps past it. | 50 * springboard. The service runtime jumps past it. |
51 */ | 51 */ |
52 bkpt | 52 bkpt |
53 | 53 |
54 add sp, #16 /* popping four arguments placed by trampoline code */ | 54 add sp, #16 /* popping four arguments placed by trampoline code */ |
55 bx r1 | 55 bx r1 |
56 | 56 |
57 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaCl_springboard_end): | 57 DEFINE_GLOBAL_HIDDEN_IDENTIFIER(NaCl_springboard_end): |
OLD | NEW |