OLD | NEW |
1 // Copyright 2012 Google Inc. All Rights Reserved. | 1 // Copyright 2012 Google Inc. All Rights Reserved. |
2 // | 2 // |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
6 // | 6 // |
7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
8 // | 8 // |
9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 // Returns true if opcode @p opcode is a special instruction. | 149 // Returns true if opcode @p opcode is a special instruction. |
150 // Memory checks for special instructions (string instructions, instructions | 150 // Memory checks for special instructions (string instructions, instructions |
151 // with prefix, etc) are handled by calling specialized functions rather than | 151 // with prefix, etc) are handled by calling specialized functions rather than |
152 // the standard memory checks. | 152 // the standard memory checks. |
153 bool IsSpecialInstruction(uint16_t opcode) { | 153 bool IsSpecialInstruction(uint16_t opcode) { |
154 switch (opcode) { | 154 switch (opcode) { |
155 case I_CMPS: | 155 case I_CMPS: |
| 156 case I_LODS: |
| 157 case I_MOVS: |
156 case I_STOS: | 158 case I_STOS: |
157 case I_MOVS: | |
158 return true; | 159 return true; |
159 | 160 |
160 default: | 161 default: |
161 return false; | 162 return false; |
162 } | 163 } |
163 } | 164 } |
164 | 165 |
165 // Decodes the first O_MEM or O_SMEM operand of @p instr, if any to the | 166 // Decodes the first O_MEM or O_SMEM operand of @p instr, if any to the |
166 // corresponding Operand. | 167 // corresponding Operand. |
167 bool DecodeMemoryAccess(const Instruction& instr, | 168 bool DecodeMemoryAccess(const Instruction& instr, |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 | 626 |
626 MemoryAccessInfo write_info_10 = | 627 MemoryAccessInfo write_info_10 = |
627 { AsanBasicBlockTransform::kWriteAccess, 10, 0, true }; | 628 { AsanBasicBlockTransform::kWriteAccess, 10, 0, true }; |
628 access_hook_param_vec.push_back(write_info_10); | 629 access_hook_param_vec.push_back(write_info_10); |
629 if (use_liveness_analysis) { | 630 if (use_liveness_analysis) { |
630 write_info_10.save_flags = false; | 631 write_info_10.save_flags = false; |
631 access_hook_param_vec.push_back(write_info_10); | 632 access_hook_param_vec.push_back(write_info_10); |
632 } | 633 } |
633 | 634 |
634 // Import the hooks for string/prefix memory accesses. | 635 // Import the hooks for string/prefix memory accesses. |
635 const _InstructionType strings[] = { I_CMPS, I_MOVS, I_STOS }; | 636 const _InstructionType strings[] = {I_CMPS, I_LODS, I_MOVS, I_STOS}; |
636 int strings_length = sizeof(strings)/sizeof(_InstructionType); | 637 int strings_length = sizeof(strings)/sizeof(_InstructionType); |
637 | 638 |
638 for (int access_size = 1; access_size <= 4; access_size *= 2) { | 639 for (int access_size = 1; access_size <= 4; access_size *= 2) { |
639 for (int inst = 0; inst < strings_length; ++inst) { | 640 for (int inst = 0; inst < strings_length; ++inst) { |
640 MemoryAccessInfo repz_inst_info = { | 641 MemoryAccessInfo repz_inst_info = { |
641 AsanBasicBlockTransform::kRepzAccess, | 642 AsanBasicBlockTransform::kRepzAccess, |
642 access_size, | 643 access_size, |
643 strings[inst], | 644 strings[inst], |
644 true | 645 true |
645 }; | 646 }; |
(...skipping 1151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1797 return left.mode < right.mode; | 1798 return left.mode < right.mode; |
1798 if (left.size != right.size) | 1799 if (left.size != right.size) |
1799 return left.size < right.size; | 1800 return left.size < right.size; |
1800 if (left.save_flags != right.save_flags) | 1801 if (left.save_flags != right.save_flags) |
1801 return left.save_flags < right.save_flags; | 1802 return left.save_flags < right.save_flags; |
1802 return left.opcode < right.opcode; | 1803 return left.opcode < right.opcode; |
1803 } | 1804 } |
1804 | 1805 |
1805 } // namespace transforms | 1806 } // namespace transforms |
1806 } // namespace instrument | 1807 } // namespace instrument |
OLD | NEW |