OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "courgette/disassembler_elf_32_x86.h" | 5 #include "courgette/disassembler_elf_32_x86.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 if (*p == 0x0F && (*(p+1) & 0xF0) == 0x80) { // Jcc long form | 150 if (*p == 0x0F && (*(p+1) & 0xF0) == 0x80) { // Jcc long form |
151 if (p[1] != 0x8A && p[1] != 0x8B) // JPE/JPO unlikely | 151 if (p[1] != 0x8A && p[1] != 0x8B) // JPE/JPO unlikely |
152 rel32 = p + 2; | 152 rel32 = p + 2; |
153 } | 153 } |
154 } | 154 } |
155 if (rel32) { | 155 if (rel32) { |
156 RVA rva = static_cast<RVA>(rel32 - adjust_pointer_to_rva); | 156 RVA rva = static_cast<RVA>(rel32 - adjust_pointer_to_rva); |
157 TypedRVAX86* rel32_rva = new TypedRVAX86(rva); | 157 TypedRVAX86* rel32_rva = new TypedRVAX86(rva); |
158 | 158 |
159 if (!rel32_rva->ComputeRelativeTarget(rel32)) { | 159 if (!rel32_rva->ComputeRelativeTarget(rel32)) { |
| 160 delete rel32_rva; |
160 return false; | 161 return false; |
161 } | 162 } |
162 | 163 |
163 RVA target_rva = rel32_rva->rva() + rel32_rva->relative_target(); | 164 RVA target_rva = rel32_rva->rva() + rel32_rva->relative_target(); |
164 // To be valid, rel32 target must be within image, and within this | 165 // To be valid, rel32 target must be within image, and within this |
165 // section. | 166 // section. |
166 if (IsValidRVA(target_rva)) { | 167 if (IsValidRVA(target_rva)) { |
167 rel32_locations_.push_back(rel32_rva); | 168 rel32_locations_.push_back(rel32_rva); |
168 #if COURGETTE_HISTOGRAM_TARGETS | 169 #if COURGETTE_HISTOGRAM_TARGETS |
169 ++rel32_target_rvas_[target_rva]; | 170 ++rel32_target_rvas_[target_rva]; |
170 #endif | 171 #endif |
171 p = rel32 + 4; | 172 p = rel32 + 4; |
172 continue; | 173 continue; |
173 } else { | 174 } else { |
174 delete rel32_rva; | 175 delete rel32_rva; |
175 } | 176 } |
176 } | 177 } |
177 p += 1; | 178 p += 1; |
178 } | 179 } |
179 | 180 |
180 return true; | 181 return true; |
181 } | 182 } |
182 | 183 |
183 } // namespace courgette | 184 } // namespace courgette |
OLD | NEW |