Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: src/trusted/validator_ragel/unreviewed/validator_x86_32.rl

Issue 10883051: Add documentation for the dynamic code modifications. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 10 matching lines...) Expand all
21 21
22 %%{ 22 %%{
23 machine x86_32_validator; 23 machine x86_32_validator;
24 alphtype unsigned char; 24 alphtype unsigned char;
25 variable p current_position; 25 variable p current_position;
26 variable pe end_of_bundle; 26 variable pe end_of_bundle;
27 variable eof end_of_bundle; 27 variable eof end_of_bundle;
28 variable cs current_state; 28 variable cs current_state;
29 29
30 action rel8_operand { 30 action rel8_operand {
31 instruction_info_collected |= RELATIVE_8BIT;
32 rel8_operand(current_position + 1, data, jump_dests, size, 31 rel8_operand(current_position + 1, data, jump_dests, size,
33 &instruction_info_collected); 32 &instruction_info_collected);
34 } 33 }
35 action rel16_operand { 34 action rel16_operand {
36 #error rel16_operand should never be used in nacl 35 #error rel16_operand should never be used in nacl
37 } 36 }
38 action rel32_operand { 37 action rel32_operand {
39 instruction_info_collected |= RELATIVE_32BIT;
40 rel32_operand(current_position + 1, data, jump_dests, size, 38 rel32_operand(current_position + 1, data, jump_dests, size,
41 &instruction_info_collected); 39 &instruction_info_collected);
42 } 40 }
43 41
44 action opcode_in_imm { 42 action last_byte_is_not_immediate {
45 instruction_info_collected |= LAST_BYTE_IS_NOT_IMMEDIATE; 43 instruction_info_collected |= LAST_BYTE_IS_NOT_IMMEDIATE;
46 } 44 }
47 45
48 include decode_x86_32 "validator_x86_32_instruction.rl"; 46 include decode_x86_32 "validator_x86_32_instruction.rl";
49 47
50 special_instruction = 48 special_instruction =
51 (0x83 0xe0 0xe0 0xff (0xd0|0xe0) | # naclcall/jmp %eax 49 (0x83 0xe0 0xe0 0xff (0xd0|0xe0) | # naclcall/jmp %eax
52 0x83 0xe1 0xe0 0xff (0xd1|0xe1) | # naclcall/jmp %ecx 50 0x83 0xe1 0xe0 0xff (0xd1|0xe1) | # naclcall/jmp %ecx
53 0x83 0xe2 0xe0 0xff (0xd2|0xe2) | # naclcall/jmp %edx 51 0x83 0xe2 0xe0 0xff (0xd2|0xe2) | # naclcall/jmp %edx
54 0x83 0xe3 0xe0 0xff (0xd3|0xe3) | # naclcall/jmp %ebx 52 0x83 0xe3 0xe0 0xff (0xd3|0xe3) | # naclcall/jmp %ebx
(...skipping 23 matching lines...) Expand all
78 @{ 76 @{
79 if (((current_position - data) & kBundleMask) != kBundleMask) 77 if (((current_position - data) & kBundleMask) != kBundleMask)
80 instruction_info_collected |= BAD_CALL_ALIGNMENT; 78 instruction_info_collected |= BAD_CALL_ALIGNMENT;
81 }; 79 };
82 80
83 main := ((call_alignment | one_instruction | special_instruction) 81 main := ((call_alignment | one_instruction | special_instruction)
84 >{ 82 >{
85 BitmapSetBit(valid_targets, current_position - data); 83 BitmapSetBit(valid_targets, current_position - data);
86 } 84 }
87 @{ 85 @{
88 if (instruction_info_collected & VALIDATION_ERRORS || 86 if ((instruction_info_collected & VALIDATION_ERRORS_MASK) ||
89 options & CALL_USER_CALLBACK_ON_EACH_INSTRUCTION) { 87 (options & CALL_USER_CALLBACK_ON_EACH_INSTRUCTION)) {
90 result &= user_callback(instruction_start, current_position, 88 result &= user_callback(instruction_start, current_position,
91 instruction_info_collected, callback_data); 89 instruction_info_collected, callback_data);
92 } 90 }
93 /* On successful match the instruction start must point to the next byte 91 /* On successful match the instruction start must point to the next byte
94 * to be able to report the new offset as the start of instruction 92 * to be able to report the new offset as the start of instruction
95 * causing error. */ 93 * causing error. */
96 instruction_start = current_position + 1; 94 instruction_start = current_position + 1;
97 instruction_info_collected = 0; 95 instruction_info_collected = 0;
98 })* 96 })*
99 $err{ 97 $err{
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 user_callback, callback_data); 159 user_callback, callback_data);
162 160
163 /* We only use malloc for a large code sequences */ 161 /* We only use malloc for a large code sequences */
164 if (size > sizeof(bitmap_word)) { 162 if (size > sizeof(bitmap_word)) {
165 free(jump_dests); 163 free(jump_dests);
166 free(valid_targets); 164 free(valid_targets);
167 } 165 }
168 if (!result) errno = EINVAL; 166 if (!result) errno = EINVAL;
169 return result; 167 return result;
170 } 168 }
OLDNEW
« no previous file with comments | « src/trusted/validator_ragel/unreviewed/validator_test.c ('k') | src/trusted/validator_ragel/unreviewed/validator_x86_64.rl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698