OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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.h" | 5 #include "courgette/disassembler_win32.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
grt (UTC plus 2)
2017/01/12 11:56:41
already included in .h
huangs
2017/01/12 19:54:42
Done.
| |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "courgette/assembly_program.h" | 14 #include "courgette/assembly_program.h" |
15 #include "courgette/courgette.h" | 15 #include "courgette/courgette.h" |
16 | 16 |
17 #if COURGETTE_HISTOGRAM_TARGETS | 17 #if COURGETTE_HISTOGRAM_TARGETS |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 // Pretend our in-memory copy is only as long as our detected length. | 217 // Pretend our in-memory copy is only as long as our detected length. |
218 ReduceLength(detected_length); | 218 ReduceLength(detected_length); |
219 | 219 |
220 if (!has_text_section()) { | 220 if (!has_text_section()) { |
221 return Bad("Resource-only executables are not yet supported"); | 221 return Bad("Resource-only executables are not yet supported"); |
222 } | 222 } |
223 | 223 |
224 return Good(); | 224 return Good(); |
225 } | 225 } |
226 | 226 |
227 bool DisassemblerWin32::Disassemble(AssemblyProgram* target) { | 227 bool DisassemblerWin32::Disassemble(AssemblyProgram* program) { |
228 if (!ok()) | 228 if (!ok()) |
229 return false; | 229 return false; |
230 | 230 |
231 target->set_image_base(image_base()); | |
232 | |
233 if (!ParseAbs32Relocs()) | 231 if (!ParseAbs32Relocs()) |
234 return false; | 232 return false; |
235 | 233 |
236 ParseRel32RelocsFromSections(); | 234 ParseRel32RelocsFromSections(); |
237 | 235 |
238 PrecomputeLabels(target); | 236 PrecomputeLabels(program); |
239 RemoveUnusedRel32Locations(target); | 237 RemoveUnusedRel32Locations(program); |
240 | 238 |
241 if (!target->GenerateInstructions( | 239 if (!program->GenerateInstructions( |
242 base::Bind(&DisassemblerWin32::ParseFile, base::Unretained(this)))) { | 240 base::Bind(&DisassemblerWin32::ParseFile, base::Unretained(this)))) { |
243 return false; | 241 return false; |
244 } | 242 } |
245 | 243 |
246 target->DefaultAssignIndexes(); | 244 program->DefaultAssignIndexes(); |
247 return true; | 245 return true; |
248 } | 246 } |
249 | 247 |
250 //////////////////////////////////////////////////////////////////////////////// | 248 //////////////////////////////////////////////////////////////////////////////// |
251 | 249 |
252 bool DisassemblerWin32::ParseRelocs(std::vector<RVA>* relocs) { | 250 bool DisassemblerWin32::ParseRelocs(std::vector<RVA>* relocs) { |
253 relocs->clear(); | 251 relocs->clear(); |
254 | 252 |
255 size_t relocs_size = base_relocation_table_.size_; | 253 size_t relocs_size = base_relocation_table_.size_; |
256 if (relocs_size == 0) | 254 if (relocs_size == 0) |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
682 directory->size_ = static_cast<uint32_t>(size); | 680 directory->size_ = static_cast<uint32_t>(size); |
683 return true; | 681 return true; |
684 } else { | 682 } else { |
685 directory->address_ = 0; | 683 directory->address_ = 0; |
686 directory->size_ = 0; | 684 directory->size_ = 0; |
687 return true; | 685 return true; |
688 } | 686 } |
689 } | 687 } |
690 | 688 |
691 } // namespace courgette | 689 } // namespace courgette |
OLD | NEW |