OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_win32_x64.h" | 5 #include "courgette/disassembler_win32_x64.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/numerics/safe_conversions.h" | 10 #include "base/numerics/safe_conversions.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 return Address64ToRVA(Read64LittleEndian(p)); | 25 return Address64ToRVA(Read64LittleEndian(p)); |
26 } | 26 } |
27 | 27 |
28 RVA DisassemblerWin32X64::Address64ToRVA(uint64_t address) const { | 28 RVA DisassemblerWin32X64::Address64ToRVA(uint64_t address) const { |
29 if (address < image_base() || address >= image_base() + size_of_image_) | 29 if (address < image_base() || address >= image_base() + size_of_image_) |
30 return kNoRVA; | 30 return kNoRVA; |
31 return base::checked_cast<RVA>(address - image_base()); | 31 return base::checked_cast<RVA>(address - image_base()); |
32 } | 32 } |
33 | 33 |
34 CheckBool DisassemblerWin32X64::EmitAbs(Label* label, | 34 CheckBool DisassemblerWin32X64::EmitAbs(Label* label, |
35 AssemblyProgram* program) { | 35 InstructionReceptor* receptor) const { |
36 return program->EmitAbs64(label); | 36 return receptor->EmitAbs64(label); |
37 } | 37 } |
38 | 38 |
39 void DisassemblerWin32X64::ParseRel32RelocsFromSection(const Section* section) { | 39 void DisassemblerWin32X64::ParseRel32RelocsFromSection(const Section* section) { |
40 // TODO(sra): use characteristic. | 40 // TODO(sra): use characteristic. |
41 bool isCode = strcmp(section->name, ".text") == 0; | 41 bool isCode = strcmp(section->name, ".text") == 0; |
42 if (!isCode) | 42 if (!isCode) |
43 return; | 43 return; |
44 | 44 |
45 FileOffset start_file_offset = section->file_offset_of_raw_data; | 45 FileOffset start_file_offset = section->file_offset_of_raw_data; |
46 FileOffset end_file_offset = start_file_offset + section->size_of_raw_data; | 46 FileOffset end_file_offset = start_file_offset + section->size_of_raw_data; |
(...skipping 11 matching lines...) Expand all Loading... |
58 finder.Find(start_pointer, end_pointer, start_rva, end_rva, abs32_locations_); | 58 finder.Find(start_pointer, end_pointer, start_rva, end_rva, abs32_locations_); |
59 finder.SwapRel32Locations(&rel32_locations_); | 59 finder.SwapRel32Locations(&rel32_locations_); |
60 | 60 |
61 #if COURGETTE_HISTOGRAM_TARGETS | 61 #if COURGETTE_HISTOGRAM_TARGETS |
62 DCHECK(rel32_target_rvas_.empty()); | 62 DCHECK(rel32_target_rvas_.empty()); |
63 finder.SwapRel32TargetRVAs(&rel32_target_rvas_); | 63 finder.SwapRel32TargetRVAs(&rel32_target_rvas_); |
64 #endif | 64 #endif |
65 } | 65 } |
66 | 66 |
67 } // namespace courgette | 67 } // namespace courgette |
OLD | NEW |