OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (c) 2011 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 | |
7 /* | |
8 * Reads in text file of hexidecimal values, and build a corresponding segment. | |
9 * | |
10 * Note: To see what the segment contains, run ncdis on the corresponding | |
11 * segment to disassemble it. | |
12 * | |
13 * Note: The purpose of this code is to make it easy to specify the contents | |
14 * of code segments using textual values, so that tests are easier to write. | |
15 * The code is NOT industrial strength and shouldn't be used except for simple | |
16 * test cases. | |
17 */ | |
18 | |
19 #ifndef NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_READ_SEGMENT_H_ | |
20 #define NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_READ_SEGMENT_H_ | |
21 | |
22 #ifndef NACL_TRUSTED_BUT_NOT_TCB | |
23 #error("This file is not meant for use in the TCB") | |
24 #endif | |
25 | |
26 #include <stdio.h> | |
27 #include "native_client/src/include/portability.h" | |
28 #include "native_client/src/trusted/validator/types_memory_model.h" | |
29 | |
30 /* Given a file, and a byte array of the given size, this function | |
31 * opens the corresponding file, reads the text of hexidecimal values, puts | |
32 * them in the byte array, and returns how many bytes were read. If any | |
33 * line begins with a pound sign (#), it is assumed to be a comment and | |
34 * ignored. If the file contains more hex values than the size of the byte | |
35 * array, the read is truncated to the size of the byte array. If the number | |
36 * of non-blank hex values aren't even, the single hex value is used as the | |
37 * the corresponding byte value. | |
38 */ | |
39 size_t NaClReadHexText(FILE* input, uint8_t* mbase, size_t mbase_size); | |
40 | |
41 /* Same as NcReadHexText, except if the first (non-comment) line has | |
42 * an at sign (@) in column 1, it assumes that the first line is specify | |
43 * a value for the initial program counter (pc). If the first line doesn't | |
44 * specify a value for the pc, zero is assumed. All other lines are | |
45 * assumed to be hex values to be converted to byte values and placed | |
46 * into the byte array. | |
47 */ | |
48 size_t NaClReadHexTextWithPc(FILE* input, NaClPcAddress* pc, | |
49 uint8_t* mbase, size_t mbase_size); | |
50 | |
51 #endif /* NATIVE_CLIENT_SRC_TRUSTED_VALIDATOR_X86_NC_READ_SEGMENT_H_ */ | |
OLD | NEW |