OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2010 The Native Client Authors. All rights reserved. | |
3 * Use of this source code is governed by a BSD-style license that can | |
4 * be found in the LICENSE file. | |
5 */ | |
6 | |
7 #include <stddef.h> | |
8 | |
9 #if !NACL_WINDOWS /* stdint is neither available nor needed on Windows */ | |
10 #include <stdint.h> | |
11 #endif | |
12 | |
13 #include "native_client/src/trusted/platform_qualify/nacl_dep_qualify.h" | |
14 #include "native_client/src/include/nacl_macros.h" | |
15 | |
16 /* Assembled equivalent of "ret" */ | |
17 #define INST_RET 0xC3 | |
18 | |
19 int NaClCheckDEP() { | |
20 /* | |
21 * We require DEP, so forward this call to the OS-specific check routine. | |
22 */ | |
23 return NaClAttemptToExecuteData(); | |
24 } | |
25 | |
26 nacl_void_thunk NaClGenerateThunk(char *buf, size_t size_in_bytes) { | |
27 /* | |
28 * Place a "ret" at buf. | |
29 */ | |
30 if (size_in_bytes < 1) return 0; | |
31 | |
32 *buf = (char) INST_RET; | |
33 | |
34 /* | |
35 * ISO C prevents a direct data->function cast, because the pointers aren't | |
36 * guaranteed to be the same size. For our platforms this is fine, but we | |
37 * verify at compile time anyway before tricking the compiler: | |
38 */ | |
39 NACL_ASSERT_SAME_SIZE(char *, nacl_void_thunk); | |
40 return (nacl_void_thunk) (uintptr_t) buf; | |
41 } | |
OLD | NEW |