| 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 * | 8 * |
| 9 * DO NOT INCLUDE EXCEPT FROM sel_ldr.h | 9 * DO NOT INCLUDE EXCEPT FROM sel_ldr.h |
| 10 * | 10 * |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 * the next two are for syscalls to do address translation, e.g., for | 42 * the next two are for syscalls to do address translation, e.g., for |
| 43 * system calls; -1 indicates an error, so the syscall can return | 43 * system calls; -1 indicates an error, so the syscall can return |
| 44 * EINVAL or EFAULT or whatever is appropriate. | 44 * EINVAL or EFAULT or whatever is appropriate. |
| 45 * | 45 * |
| 46 * the latter two interfaces are for use everywhere else in the loader | 46 * the latter two interfaces are for use everywhere else in the loader |
| 47 * / service runtime and will log a fatal error and abort the process | 47 * / service runtime and will log a fatal error and abort the process |
| 48 * when an error is detected. (0 is not a good error indicator, since | 48 * when an error is detected. (0 is not a good error indicator, since |
| 49 * 0 is a valid user address.) | 49 * 0 is a valid user address.) |
| 50 */ | 50 */ |
| 51 | 51 |
| 52 #include "native_client/src/trusted/service_runtime/arch/sel_ldr_arch.h" |
| 53 |
| 52 static INLINE uintptr_t NaClUserToSysAddrNullOkay(struct NaClApp *nap, | 54 static INLINE uintptr_t NaClUserToSysAddrNullOkay(struct NaClApp *nap, |
| 53 uintptr_t uaddr) { | 55 uintptr_t uaddr) { |
| 54 if (((uintptr_t) 1U << nap->addr_bits <= uaddr)) { | 56 if (((uintptr_t) 1U << nap->addr_bits <= uaddr)) { |
| 55 return kNaClBadAddress; | 57 return kNaClBadAddress; |
| 56 } | 58 } |
| 57 return uaddr + nap->mem_start; | 59 return uaddr + nap->mem_start; |
| 58 } | 60 } |
| 59 | 61 |
| 60 static INLINE uintptr_t NaClUserToSysAddr(struct NaClApp *nap, | 62 static INLINE uintptr_t NaClUserToSysAddr(struct NaClApp *nap, |
| 61 uintptr_t uaddr) { | 63 uintptr_t uaddr) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 # else | 183 # else |
| 182 # error "What kind of x86 are we on anyway?!?" | 184 # error "What kind of x86 are we on anyway?!?" |
| 183 # endif | 185 # endif |
| 184 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm | 186 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_arm |
| 185 UNREFERENCED_PARAMETER(nap); | 187 UNREFERENCED_PARAMETER(nap); |
| 186 addr &= ~NACL_CONTROL_FLOW_MASK; | 188 addr &= ~NACL_CONTROL_FLOW_MASK; |
| 187 # if defined(NACL_TARGET_ARM_THUMB2_MODE) | 189 # if defined(NACL_TARGET_ARM_THUMB2_MODE) |
| 188 addr |= 0xf; | 190 addr |= 0xf; |
| 189 # endif /* defined(NACL_TARGET_ARM_THUMB2_MODE) */ | 191 # endif /* defined(NACL_TARGET_ARM_THUMB2_MODE) */ |
| 190 return addr; | 192 return addr; |
| 193 #elif NACL_ARCH(NACL_BUILD_ARCH) == NACL_mips |
| 194 UNREFERENCED_PARAMETER(nap); |
| 195 return addr & NACL_CONTROL_FLOW_MASK; |
| 191 #else | 196 #else |
| 192 # error "What architecture are we on?!?" | 197 # error "What architecture are we on?!?" |
| 193 #endif | 198 #endif |
| 194 } | 199 } |
| 195 | 200 |
| 196 static INLINE int NaClIsValidJumpTarget(struct NaClApp *nap, | 201 static INLINE int NaClIsValidJumpTarget(struct NaClApp *nap, |
| 197 uintptr_t addr) { | 202 uintptr_t addr) { |
| 198 if (0 != (addr & (((uintptr_t) nap->bundle_size) - 1))) { | 203 if (0 != (addr & (((uintptr_t) nap->bundle_size) - 1))) { |
| 199 return 0; | 204 return 0; |
| 200 } | 205 } |
| 201 return addr < nap->dynamic_text_end; | 206 return addr < nap->dynamic_text_end; |
| 202 } | 207 } |
| OLD | NEW |