| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "courgette/disassembler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (section == NULL) | 110 if (section == NULL) |
| 111 break; | 111 break; |
| 112 if (file_offset < section->file_offset_of_raw_data) | 112 if (file_offset < section->file_offset_of_raw_data) |
| 113 file_offset = section->file_offset_of_raw_data; | 113 file_offset = section->file_offset_of_raw_data; |
| 114 ParseRel32RelocsFromSection(section); | 114 ParseRel32RelocsFromSection(section); |
| 115 file_offset += section->size_of_raw_data; | 115 file_offset += section->size_of_raw_data; |
| 116 } | 116 } |
| 117 std::sort(rel32_locations_.begin(), rel32_locations_.end()); | 117 std::sort(rel32_locations_.begin(), rel32_locations_.end()); |
| 118 | 118 |
| 119 #if COURGETTE_HISTOGRAM_TARGETS | 119 #if COURGETTE_HISTOGRAM_TARGETS |
| 120 LOG(INFO) << "abs32_locations_ " << abs32_locations_.size(); | 120 VLOG(1) << "abs32_locations_ " << abs32_locations_.size() |
| 121 LOG(INFO) << "rel32_locations_ " << rel32_locations_.size(); | 121 << "\nrel32_locations_ " << rel32_locations_.size() |
| 122 LOG(INFO) << "abs32_target_rvas_ " << abs32_target_rvas_.size(); | 122 << "\nabs32_target_rvas_ " << abs32_target_rvas_.size() |
| 123 LOG(INFO) << "rel32_target_rvas_ " << rel32_target_rvas_.size(); | 123 << "\nrel32_target_rvas_ " << rel32_target_rvas_.size(); |
| 124 | 124 |
| 125 int common = 0; | 125 int common = 0; |
| 126 std::map<RVA, int>::iterator abs32_iter = abs32_target_rvas_.begin(); | 126 std::map<RVA, int>::iterator abs32_iter = abs32_target_rvas_.begin(); |
| 127 std::map<RVA, int>::iterator rel32_iter = rel32_target_rvas_.begin(); | 127 std::map<RVA, int>::iterator rel32_iter = rel32_target_rvas_.begin(); |
| 128 while (abs32_iter != abs32_target_rvas_.end() && | 128 while (abs32_iter != abs32_target_rvas_.end() && |
| 129 rel32_iter != rel32_target_rvas_.end()) { | 129 rel32_iter != rel32_target_rvas_.end()) { |
| 130 if (abs32_iter->first < rel32_iter->first) | 130 if (abs32_iter->first < rel32_iter->first) |
| 131 ++abs32_iter; | 131 ++abs32_iter; |
| 132 else if (rel32_iter->first < abs32_iter->first) | 132 else if (rel32_iter->first < abs32_iter->first) |
| 133 ++rel32_iter; | 133 ++rel32_iter; |
| 134 else { | 134 else { |
| 135 ++common; | 135 ++common; |
| 136 ++abs32_iter; | 136 ++abs32_iter; |
| 137 ++rel32_iter; | 137 ++rel32_iter; |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 LOG(INFO) << "common " << common; | 140 VLOG(1) << "common " << common; |
| 141 #endif | 141 #endif |
| 142 } | 142 } |
| 143 | 143 |
| 144 void DisassemblerWin32X86::ParseRel32RelocsFromSection(const Section* section) { | 144 void DisassemblerWin32X86::ParseRel32RelocsFromSection(const Section* section) { |
| 145 // TODO(sra): use characteristic. | 145 // TODO(sra): use characteristic. |
| 146 bool isCode = strcmp(section->name, ".text") == 0; | 146 bool isCode = strcmp(section->name, ".text") == 0; |
| 147 if (!isCode) | 147 if (!isCode) |
| 148 return; | 148 return; |
| 149 | 149 |
| 150 uint32 start_file_offset = section->file_offset_of_raw_data; | 150 uint32 start_file_offset = section->file_offset_of_raw_data; |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 delete pe_info; | 426 delete pe_info; |
| 427 *output = program; | 427 *output = program; |
| 428 return C_OK; | 428 return C_OK; |
| 429 } | 429 } |
| 430 | 430 |
| 431 void DeleteAssemblyProgram(AssemblyProgram* program) { | 431 void DeleteAssemblyProgram(AssemblyProgram* program) { |
| 432 delete program; | 432 delete program; |
| 433 } | 433 } |
| 434 | 434 |
| 435 } // namespace courgette | 435 } // namespace courgette |
| OLD | NEW |