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 <memory> |
7 #include <vector> | 8 #include <vector> |
8 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "courgette/assembly_program.h" | 11 #include "courgette/assembly_program.h" |
12 #include "courgette/courgette.h" | 12 #include "courgette/courgette.h" |
13 | 13 |
14 namespace courgette { | 14 namespace courgette { |
15 | 15 |
16 CheckBool DisassemblerElf32X86::TypedRVAX86::ComputeRelativeTarget( | 16 CheckBool DisassemblerElf32X86::TypedRVAX86::ComputeRelativeTarget( |
17 const uint8_t* op_pointer) { | 17 const uint8_t* op_pointer) { |
18 set_relative_target(Read32LittleEndian(op_pointer) + 4); | 18 set_relative_target(Read32LittleEndian(op_pointer) + 4); |
19 return true; | 19 return true; |
20 } | 20 } |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 if (abs32_pos != abs32_locations_.end()) { | 171 if (abs32_pos != abs32_locations_.end()) { |
172 if (*abs32_pos < rel32_rva + 4) { | 172 if (*abs32_pos < rel32_rva + 4) { |
173 // Beginning of abs32 reloc is before end of rel32 reloc so they | 173 // Beginning of abs32 reloc is before end of rel32 reloc so they |
174 // overlap. Skip four bytes past the abs32 reloc. | 174 // overlap. Skip four bytes past the abs32 reloc. |
175 RVA current_rva = static_cast<RVA>(p - adjust_pointer_to_rva); | 175 RVA current_rva = static_cast<RVA>(p - adjust_pointer_to_rva); |
176 p += (*abs32_pos + 4) - current_rva; | 176 p += (*abs32_pos + 4) - current_rva; |
177 continue; | 177 continue; |
178 } | 178 } |
179 } | 179 } |
180 | 180 |
181 scoped_ptr<TypedRVAX86> typed_rel32_rva(new TypedRVAX86(rel32_rva)); | 181 std::unique_ptr<TypedRVAX86> typed_rel32_rva(new TypedRVAX86(rel32_rva)); |
182 if (!typed_rel32_rva->ComputeRelativeTarget(rel32)) | 182 if (!typed_rel32_rva->ComputeRelativeTarget(rel32)) |
183 return false; | 183 return false; |
184 | 184 |
185 RVA target_rva = typed_rel32_rva->rva() + | 185 RVA target_rva = typed_rel32_rva->rva() + |
186 typed_rel32_rva->relative_target(); | 186 typed_rel32_rva->relative_target(); |
187 if (IsValidTargetRVA(target_rva)) { | 187 if (IsValidTargetRVA(target_rva)) { |
188 rel32_locations_.push_back(typed_rel32_rva.release()); | 188 rel32_locations_.push_back(typed_rel32_rva.release()); |
189 #if COURGETTE_HISTOGRAM_TARGETS | 189 #if COURGETTE_HISTOGRAM_TARGETS |
190 ++rel32_target_rvas_[target_rva]; | 190 ++rel32_target_rvas_[target_rva]; |
191 #endif | 191 #endif |
192 p = rel32 + 4; | 192 p = rel32 + 4; |
193 continue; | 193 continue; |
194 } | 194 } |
195 } | 195 } |
196 p += 1; | 196 p += 1; |
197 } | 197 } |
198 | 198 |
199 return true; | 199 return true; |
200 } | 200 } |
201 | 201 |
202 } // namespace courgette | 202 } // namespace courgette |
OLD | NEW |