1/*
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.
5 *
6 * The assembly is correctly bundle-aligned and organized with whitespace
7 * between each bundle, so the bundle_lock directives are not strictly
8 * necessary, but they prevent clang's auto-sandboxer from redundantly
9 * sandboxing the code.
10 */
11
12#include "native_client/src/include/arm_sandbox.h"
13
14        /*
15         * assume 32-byte trampoline slots, 16-byte bundles.
16         */
17#define GETTIMEOFDAY_ADDR 0x10500
18
19        .data
20timebuf:
21        .space 0x200 /* enough for a timeval */
22
23        .text
24        .globl SyscallReturnIsSandboxed
25        .p2align 4
26SyscallReturnIsSandboxed:
27        nop
28        push {lr}
29        ldr r0, addrOfTimeBuf
30        mov r1, #0
31
32        adr lr, bad
33        ldr r2, addrOfGetTimeOfDaySyscallAddr
34        .bundle_lock
35        bic r2, r2, #0xf000000f
36        bx  r2
37        .bundle_unlock
38
39        eor r0, r0, #1
40bad:    pop {lr}
41        .bundle_lock
42        bic lr, lr, #0xf000000f
43        bx lr
44        .bundle_unlock
45
46        .p2align 4
47        .word NACL_INSTR_ARM_LITERAL_POOL_HEAD
48        /*
49         * Put a disallowed instruction here to ensure that the bkpt
50         * data bundle marker works.  If the marker does not work, then
51         * whether this code passes the validator is a matter of chance.
52         */
53        mov pc, r0
54addrOfGetTimeOfDaySyscallAddr:
55        .word GETTIMEOFDAY_ADDR
56addrOfTimeBuf:
57        .word timebuf
58