Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 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 | 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 /* | 7 /* |
| 8 * NaCl Simple/secure ELF loader (NaCl SEL). | 8 * NaCl Simple/secure ELF loader (NaCl SEL). |
| 9 * | 9 * |
| 10 * NOTE: This header is ALSO included by assembler files and hence | 10 * NOTE: This header is ALSO included by assembler files and hence |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 # define NACL_USERRET_FIX (-0x4) | 177 # define NACL_USERRET_FIX (-0x4) |
| 178 # define NACL_SYSARGS_FIX (0) | 178 # define NACL_SYSARGS_FIX (0) |
| 179 /* | 179 /* |
| 180 * System V Application Binary Interface, Intel386 Architcture | 180 * System V Application Binary Interface, Intel386 Architcture |
| 181 * Processor Supplement, section 3-10, says stack alignment is | 181 * Processor Supplement, section 3-10, says stack alignment is |
| 182 * 4-bytes, but gcc-generated code can require 16-byte alignment | 182 * 4-bytes, but gcc-generated code can require 16-byte alignment |
| 183 * (depending on compiler flags in force) for SSE instructions, so we | 183 * (depending on compiler flags in force) for SSE instructions, so we |
| 184 * must do so here as well. | 184 * must do so here as well. |
| 185 */ | 185 */ |
| 186 # define NACL_STACK_ALIGN_MASK (0xf) | 186 # define NACL_STACK_ALIGN_MASK (0xf) |
| 187 # define NACL_STACK_ARG_SIZE (0) | |
| 187 # define NACL_STACK_GETS_ARG (1) | 188 # define NACL_STACK_GETS_ARG (1) |
| 188 # define NACL_STACK_PAD_BELOW_ALIGN (4) | 189 # define NACL_STACK_PAD_BELOW_ALIGN (4) |
| 189 # define NACL_STACK_RED_ZONE (0) | 190 # define NACL_STACK_RED_ZONE (0) |
| 190 | 191 |
| 191 # elif NACL_BUILD_SUBARCH == 64 | 192 # elif NACL_BUILD_SUBARCH == 64 |
| 192 /* | 193 /* |
| 193 * The untrusted stack looks like this on x86-64: | 194 * The untrusted stack looks like this on x86-64: |
| 194 * rsp-0x08: 8 byte return address pushed by untrusted code's call | 195 * rsp-0x08: 8 byte return address pushed by untrusted code's call |
| 195 * rsp-0x10: 8 byte return address pushed by the trampoline's call | 196 * rsp-0x10: 8 byte return address pushed by the trampoline's call |
| 196 * rsp-0x28: 0x18 bytes of syscall arguments saved by NaClSyscallSeg | 197 * rsp-0x28: 0x18 bytes of syscall arguments saved by NaClSyscallSeg |
| 197 */ | 198 */ |
| 198 # define NACL_TRAMPRET_FIX (-0x10) | 199 # define NACL_TRAMPRET_FIX (-0x10) |
| 199 # define NACL_USERRET_FIX (-0x8) | 200 # define NACL_USERRET_FIX (-0x8) |
| 200 # define NACL_SYSARGS_FIX (-0x28) | 201 # define NACL_SYSARGS_FIX (-0x28) |
| 201 /* | 202 /* |
| 202 * System V Application Binary Interface, AMD64 Architecture Processor | 203 * System V Application Binary Interface, AMD64 Architecture Processor |
| 203 * Supplement, at http://www.x86-64.org/documentation/abi.pdf, section | 204 * Supplement, at http://www.x86-64.org/documentation/abi.pdf, section |
| 204 * 3.2.2 discusses stack alignment. | 205 * 3.2.2 discusses stack alignment. |
| 205 */ | 206 */ |
| 206 # define NACL_STACK_ALIGN_MASK (0xf) | 207 # define NACL_STACK_ALIGN_MASK (0xf) |
| 208 # define NACL_STACK_ARG_SIZE (0) | |
| 207 # define NACL_STACK_GETS_ARG (0) | 209 # define NACL_STACK_GETS_ARG (0) |
| 208 # define NACL_STACK_PAD_BELOW_ALIGN (8) | 210 # define NACL_STACK_PAD_BELOW_ALIGN (8) |
| 209 # define NACL_STACK_RED_ZONE (128) | 211 # define NACL_STACK_RED_ZONE (128) |
| 210 # else /* NACL_BUILD_SUBARCH */ | 212 # else /* NACL_BUILD_SUBARCH */ |
| 211 # error Unknown platform! | 213 # error Unknown platform! |
| 212 # endif /* NACL_BUILD_SUBARCH */ | 214 # endif /* NACL_BUILD_SUBARCH */ |
| 213 | 215 |
| 214 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | 216 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm |
| 215 | 217 |
| 216 # define NACL_BLOCK_SHIFT (4) | 218 # define NACL_BLOCK_SHIFT (4) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 232 # define NACL_SYSARGS_FIX (-0x10) | 234 # define NACL_SYSARGS_FIX (-0x10) |
| 233 /* | 235 /* |
| 234 * See ARM Procedure Call Standard, ARM IHI 0042D, section 5.2.1.2. | 236 * See ARM Procedure Call Standard, ARM IHI 0042D, section 5.2.1.2. |
| 235 * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042a/IHI0042A_aapcs.pdf | 237 * http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042a/IHI0042A_aapcs.pdf |
| 236 * -- the "public" stack alignment is required to be 8 bytes. | 238 * -- the "public" stack alignment is required to be 8 bytes. |
| 237 * While ARM vector loads and stores work with misaligned addresses, there can | 239 * While ARM vector loads and stores work with misaligned addresses, there can |
| 238 * be performance penalties on some microarchitectures. To improve the | 240 * be performance penalties on some microarchitectures. To improve the |
| 239 * performance of vector instructions, we increase this to 16. | 241 * performance of vector instructions, we increase this to 16. |
| 240 */ | 242 */ |
| 241 # define NACL_STACK_ALIGN_MASK (0xf) | 243 # define NACL_STACK_ALIGN_MASK (0xf) |
| 244 # define NACL_STACK_ARG_SIZE (0) | |
| 242 # define NACL_STACK_GETS_ARG (0) | 245 # define NACL_STACK_GETS_ARG (0) |
| 243 # define NACL_STACK_PAD_BELOW_ALIGN (0) | 246 # define NACL_STACK_PAD_BELOW_ALIGN (0) |
| 244 # define NACL_STACK_RED_ZONE (0) | 247 # define NACL_STACK_RED_ZONE (0) |
| 245 | 248 |
| 246 /* | 249 /* |
| 247 * NOTE: Used by various assembler files, needs to be | 250 * NOTE: Used by various assembler files, needs to be |
| 248 * synchronized with NaClThreadContext | 251 * synchronized with NaClThreadContext |
| 249 */ | 252 */ |
| 250 # define NACL_CALLEE_SAVE_LIST {r4, r5, r6, r7, r8, r9, r10, fp, sp} | 253 # define NACL_CALLEE_SAVE_LIST {r4, r5, r6, r7, r8, r9, r10, fp, sp} |
| 251 | 254 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 263 * The untrusted stack looks like this on MIPS: | 266 * The untrusted stack looks like this on MIPS: |
| 264 * $sp+0x10: 0-8 bytes for 0-2 syscall arguments saved by untrusted code | 267 * $sp+0x10: 0-8 bytes for 0-2 syscall arguments saved by untrusted code |
| 265 * $sp+0x00: 16 bytes for 4 syscall arguments saved by NaClSyscallSeg | 268 * $sp+0x00: 16 bytes for 4 syscall arguments saved by NaClSyscallSeg |
| 266 * $sp-0x04: 4 byte user return address saved by NaClSyscallSeg | 269 * $sp-0x04: 4 byte user return address saved by NaClSyscallSeg |
| 267 * $sp-0x08: 4 byte trampoline address saved by NaClSyscallSeg | 270 * $sp-0x08: 4 byte trampoline address saved by NaClSyscallSeg |
| 268 */ | 271 */ |
| 269 # define NACL_TRAMPRET_FIX (-0x8) | 272 # define NACL_TRAMPRET_FIX (-0x8) |
| 270 # define NACL_USERRET_FIX (-0x4) | 273 # define NACL_USERRET_FIX (-0x4) |
| 271 # define NACL_SYSARGS_FIX (0) | 274 # define NACL_SYSARGS_FIX (0) |
| 272 # define NACL_STACK_ALIGN_MASK (0x7) | 275 # define NACL_STACK_ALIGN_MASK (0x7) |
| 276 /* | |
| 277 * The MIPS o32 ABI requires callers to reserve 16 bytes above the stack | |
| 278 * pointer, which the callee can spill arguments to. | |
| 279 */ | |
| 280 # define NACL_STACK_ARG_SIZE (0x10) | |
|
Mark Seaborn
2013/03/07 16:07:53
Maybe calls this "ARGS_SIZE" rather than "ARG_SIZE
petarj
2013/03/07 17:33:12
Done.
| |
| 273 # define NACL_STACK_GETS_ARG (0) | 281 # define NACL_STACK_GETS_ARG (0) |
| 274 # define NACL_STACK_PAD_BELOW_ALIGN (0) | 282 # define NACL_STACK_PAD_BELOW_ALIGN (0) |
| 275 # define NACL_STACK_RED_ZONE (0) | 283 # define NACL_STACK_RED_ZONE (0) |
| 276 /* 16 byte bundles */ | 284 /* 16 byte bundles */ |
| 277 | 285 |
| 278 #else /* NACL_ARCH(NACL_BUILD_ARCH) */ | 286 #else /* NACL_ARCH(NACL_BUILD_ARCH) */ |
| 279 | 287 |
| 280 # error Unknown platform! | 288 # error Unknown platform! |
| 281 | 289 |
| 282 #endif /* NACL_ARCH(NACL_BUILD_ARCH) */ | 290 #endif /* NACL_ARCH(NACL_BUILD_ARCH) */ |
| 283 | 291 |
| 284 #ifdef __ASSEMBLER__ | 292 #ifdef __ASSEMBLER__ |
| 285 # if NACL_WINDOWS | 293 # if NACL_WINDOWS |
| 286 # define NACL_RODATA .section .rdata, "dr" | 294 # define NACL_RODATA .section .rdata, "dr" |
| 287 # elif NACL_OSX | 295 # elif NACL_OSX |
| 288 # define NACL_RODATA .section __TEXT, __const | 296 # define NACL_RODATA .section __TEXT, __const |
| 289 # else | 297 # else |
| 290 # define NACL_RODATA .section .rodata, "a" | 298 # define NACL_RODATA .section .rodata, "a" |
| 291 # endif | 299 # endif |
| 292 #endif | 300 #endif |
| 293 | 301 |
| 294 #endif /* NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_NACL_CONFIG_H_ */ | 302 #endif /* NATIVE_CLIENT_SRC_TRUSTED_SERVICE_RUNTIME_NACL_CONFIG_H_ */ |
| OLD | NEW |