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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 const uint8_t kInt3[] = {0xCC}; | 119 const uint8_t kInt3[] = {0xCC}; |
120 | 120 |
121 // VEX encoded instructions that Distorm doesn't handle properly. | 121 // VEX encoded instructions that Distorm doesn't handle properly. |
122 const std::vector<std::vector<uint8_t>> kVexInstructions = { | 122 const std::vector<std::vector<uint8_t>> kVexInstructions = { |
123 // AVX instructions. | 123 // AVX instructions. |
124 {0xC4, 0xE3, 0xFD, 0x00, 0xED, 0x44}, // vpermq | 124 {0xC4, 0xE3, 0xFD, 0x00, 0xED, 0x44}, // vpermq |
125 {0xC4, 0xE2, 0x4D, 0x36, 0xC0}, // vpermd | 125 {0xC4, 0xE2, 0x4D, 0x36, 0xC0}, // vpermd |
126 {0xC4, 0xE2, 0x7D, 0x5A, 0x45, 0xD0}, // vbroadcasti128 | 126 {0xC4, 0xE2, 0x7D, 0x5A, 0x45, 0xD0}, // vbroadcasti128 |
127 {0xC4, 0xE3, 0x7D, 0x38, 0x2C, 0x0F, 0x01}, // vinserti128 | 127 {0xC4, 0xE3, 0x7D, 0x38, 0x2C, 0x0F, 0x01}, // vinserti128 |
128 {0xC4, 0xE2, 0x79, 0x78, 0xC0}, // vpbroadcastb | 128 {0xC4, 0xE2, 0x79, 0x78, 0xC0}, // vpbroadcastb |
129 {0xC4, 0xE2, 0x7D, 0x58, 0x40, 0x04}, // vpbroadcastd | 129 {0xC4, 0xE2, 0x79, 0x78, 0x40, 0x04}, // vpbroadcastb (2 operands) |
| 130 {0xC4, 0xE2, 0x7D, 0x58, 0xC0}, // vpbroadcastd |
| 131 {0xC4, 0xE2, 0x7D, 0x58, 0x40, 0x04}, // vpbroadcastd (2 operands) |
130 {0xC4, 0xE2, 0x7D, 0x18, 0xC0}, // vbroadcastss | 132 {0xC4, 0xE2, 0x7D, 0x18, 0xC0}, // vbroadcastss |
131 {0xC4, 0xE3, 0x7D, 0x39, 0xC8, 0x01}, // vextracti128 | 133 {0xC4, 0xE3, 0x7D, 0x39, 0xC8, 0x01}, // vextracti128 |
132 {0xC4, 0xE2, 0x7D, 0x90, 0x1C, 0x88}, // vpgatherdd | 134 {0xC4, 0xE2, 0x7D, 0x90, 0x1C, 0x88}, // vpgatherdd |
133 {0xC4, 0xE2, 0x7D, 0x8C, 0x00}, // vpmaskmovd | 135 {0xC4, 0xE2, 0x7D, 0x8C, 0x00}, // vpmaskmovd |
134 {0xC4, 0xE2, 0x7D, 0x8E, 0x90}, // vpmaskmovd | |
135 | 136 |
136 // F16C instructions. | 137 // F16C instructions. |
137 {0xC4, 0xE3, 0x79, 0x1D, 0xC8, 0x00}, // vcvtps2ph | 138 {0xC4, 0xE3, 0x79, 0x1D, 0xC8, 0x00}, // vcvtps2ph |
138 {0xC4, 0xE2, 0x79, 0x13, 0xE0}, // vcvtps2ps | 139 {0xC4, 0xE2, 0x79, 0x13, 0xE0}, // vcvtps2ps |
139 }; | 140 }; |
140 | 141 |
141 void TestBadlyDecodedInstruction(const uint8_t* code, size_t code_length) { | 142 void TestBadlyDecodedInstruction(const uint8_t* code, size_t code_length) { |
142 _DInst inst[1] = {}; | 143 _DInst inst[1] = {}; |
143 unsigned int inst_count = 0; | 144 unsigned int inst_count = 0; |
144 _DecodeResult result = RawDecomposeCode( | 145 _DecodeResult result = RawDecomposeCode( |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 379 } |
379 | 380 |
380 TEST(DisassemblerUtilTest, TestBadlyDecodedCRC32) { | 381 TEST(DisassemblerUtilTest, TestBadlyDecodedCRC32) { |
381 // CRC32 with a 16 bit operand size prefix is not handled correctly by | 382 // CRC32 with a 16 bit operand size prefix is not handled correctly by |
382 // distorm. | 383 // distorm. |
383 EXPECT_NO_FATAL_FAILURE( | 384 EXPECT_NO_FATAL_FAILURE( |
384 TestBadlyDecodedInstruction(kCrc32CX, sizeof(kCrc32CX))); | 385 TestBadlyDecodedInstruction(kCrc32CX, sizeof(kCrc32CX))); |
385 } | 386 } |
386 | 387 |
387 } // namespace core | 388 } // namespace core |
OLD | NEW |