OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "sandbox/linux/seccomp-bpf/syscall.h" | 5 #include "sandbox/linux/seccomp-bpf/syscall.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // interworking. That's OK, as we don't make any of the assembly | 126 // interworking. That's OK, as we don't make any of the assembly |
127 // symbols public. They are all local to this file. | 127 // symbols public. They are all local to this file. |
128 ".text\n" | 128 ".text\n" |
129 ".align 2\n" | 129 ".align 2\n" |
130 ".type SyscallAsm, %function\n" | 130 ".type SyscallAsm, %function\n" |
131 #if defined(__thumb__) | 131 #if defined(__thumb__) |
132 ".thumb_func\n" | 132 ".thumb_func\n" |
133 #else | 133 #else |
134 ".arm\n" | 134 ".arm\n" |
135 #endif | 135 #endif |
136 "SyscallAsm:.fnstart\n" | 136 "SyscallAsm:\n" |
| 137 #if !defined(__native_client_nonsfi__) |
| 138 // .fnstart and .fnend pseudo operations creates unwind table. |
| 139 // It also creates a reference to the symbol __aeabi_unwind_cpp_pr0, which |
| 140 // is not provided by PNaCl toolchain. Disable it. |
| 141 ".fnstart\n" |
| 142 #endif |
137 "@ args = 0, pretend = 0, frame = 8\n" | 143 "@ args = 0, pretend = 0, frame = 8\n" |
138 "@ frame_needed = 1, uses_anonymous_args = 0\n" | 144 "@ frame_needed = 1, uses_anonymous_args = 0\n" |
139 #if defined(__thumb__) | 145 #if defined(__thumb__) |
140 ".cfi_startproc\n" | 146 ".cfi_startproc\n" |
141 "push {r7, lr}\n" | 147 "push {r7, lr}\n" |
| 148 ".save {r7, lr}\n" |
142 ".cfi_offset 14, -4\n" | 149 ".cfi_offset 14, -4\n" |
143 ".cfi_offset 7, -8\n" | 150 ".cfi_offset 7, -8\n" |
144 "mov r7, sp\n" | |
145 ".cfi_def_cfa_register 7\n" | |
146 ".cfi_def_cfa_offset 8\n" | 151 ".cfi_def_cfa_offset 8\n" |
147 #else | 152 #else |
148 "stmfd sp!, {fp, lr}\n" | 153 "stmfd sp!, {fp, lr}\n" |
149 "add fp, sp, #4\n" | 154 "add fp, sp, #4\n" |
150 #endif | 155 #endif |
151 // Check if "r0" is negative. If so, do not attempt to make a | 156 // Check if "r0" is negative. If so, do not attempt to make a |
152 // system call. Instead, compute the return address that is visible | 157 // system call. Instead, compute the return address that is visible |
153 // to the kernel after we execute "swi 0". This address can be | 158 // to the kernel after we execute "swi 0". This address can be |
154 // used as a marker that BPF code inspects. | 159 // used as a marker that BPF code inspects. |
155 "cmp r0, #0\n" | 160 "cmp r0, #0\n" |
(...skipping 14 matching lines...) Expand all Loading... |
170 // Enter the kernel | 175 // Enter the kernel |
171 "swi 0\n" | 176 "swi 0\n" |
172 // Restore the frame pointer. Also restore the program counter from | 177 // Restore the frame pointer. Also restore the program counter from |
173 // the link register; this makes us return to the caller. | 178 // the link register; this makes us return to the caller. |
174 #if defined(__thumb__) | 179 #if defined(__thumb__) |
175 "2:pop {r7, pc}\n" | 180 "2:pop {r7, pc}\n" |
176 ".cfi_endproc\n" | 181 ".cfi_endproc\n" |
177 #else | 182 #else |
178 "2:ldmfd sp!, {fp, pc}\n" | 183 "2:ldmfd sp!, {fp, pc}\n" |
179 #endif | 184 #endif |
| 185 #if !defined(__native_client_nonsfi__) |
| 186 // Do not use .fnstart and .fnend for PNaCl toolchain. See above comment, |
| 187 // for more details. |
180 ".fnend\n" | 188 ".fnend\n" |
| 189 #endif |
181 "9:.size SyscallAsm, 9b-SyscallAsm\n" | 190 "9:.size SyscallAsm, 9b-SyscallAsm\n" |
182 #elif defined(__mips__) | 191 #elif defined(__mips__) |
183 ".text\n" | 192 ".text\n" |
184 ".align 4\n" | 193 ".align 4\n" |
185 ".type SyscallAsm, @function\n" | 194 ".type SyscallAsm, @function\n" |
186 "SyscallAsm:.ent SyscallAsm\n" | 195 "SyscallAsm:.ent SyscallAsm\n" |
187 ".frame $sp, 40, $ra\n" | 196 ".frame $sp, 40, $ra\n" |
188 ".set push\n" | 197 ".set push\n" |
189 ".set noreorder\n" | 198 ".set noreorder\n" |
190 "addiu $sp, $sp, -40\n" | 199 "addiu $sp, $sp, -40\n" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 412 } |
404 | 413 |
405 // Set an error status so it can be used outside of this function | 414 // Set an error status so it can be used outside of this function |
406 *err_ret = err_stat; | 415 *err_ret = err_stat; |
407 | 416 |
408 return ret; | 417 return ret; |
409 } | 418 } |
410 #endif // defined(__mips__) | 419 #endif // defined(__mips__) |
411 | 420 |
412 } // namespace sandbox | 421 } // namespace sandbox |
OLD | NEW |