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
4 * found in the LICENSE file.
9 #include "native_client/src/shared/platform/nacl_check.h"
10 #include "native_client/src/trusted/service_runtime/nacl_globals.h"
11 #include "native_client/src/trusted/service_runtime/sel_ldr.h"
12 #include "native_client/src/trusted/service_runtime/arch/arm/sel_ldr_arm.h"
13 #include "native_client/src/trusted/service_runtime/arch/arm/tramp_arm.h"
16 /* NOTE(robertm): the trampoline organization for ARM is currenly assuming
17 * NACL_TRAMPOLINE_SIZE == 32. This is contrary to the bundle size
18 * which is 16. The reason for this is tramp.S which has a payload
19 * 5 instr + one data item
22 void NaClPatchOneTrampoline(struct NaClApp *nap,
23 uintptr_t target_addr) {
24 size_t trampoline_size = ((uintptr_t) &NaCl_trampoline_seg_end
25 - (uintptr_t) &NaCl_trampoline_seg_code);
27 UNREFERENCED_PARAMETER(nap);
29 CHECK(trampoline_size == NACL_SYSCALL_BLOCK_SIZE);
30 memcpy((void *) target_addr, &NaCl_trampoline_seg_code,
31 NACL_SYSCALL_BLOCK_SIZE);
35 void NaClFillMemoryRegionWithHalt(void *start, size_t size) {
36 uint32_t *inst = (uint32_t *) start;
39 CHECK(sizeof *inst == NACL_HALT_LEN);
40 CHECK(0 == size % NACL_HALT_LEN);
41 /* check that the region start is 4 bytes aligned */
42 CHECK(0 == (uint32_t)start % NACL_HALT_LEN);
44 for (i = 0; i < (size / NACL_HALT_LEN); i++)
45 inst[i] = NACL_HALT_OPCODE;
49 void NaClFillTrampolineRegion(struct NaClApp *nap) {
50 NaClFillMemoryRegionWithHalt((void *)(nap->mem_start + NACL_TRAMPOLINE_START),
51 NACL_TRAMPOLINE_SIZE);
55 void NaClLoadSpringboard(struct NaClApp *nap) {
56 UNREFERENCED_PARAMETER(nap);