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_elf_32.h" | 5 #include "courgette/disassembler_elf_32.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 } | 398 } |
399 | 399 |
400 // Rest of the section (if any) | 400 // Rest of the section (if any) |
401 return ParseSimpleRegion(file_offset, section_end, program); | 401 return ParseSimpleRegion(file_offset, section_end, program); |
402 } | 402 } |
403 | 403 |
404 CheckBool DisassemblerElf32::ParseSimpleRegion( | 404 CheckBool DisassemblerElf32::ParseSimpleRegion( |
405 size_t start_file_offset, | 405 size_t start_file_offset, |
406 size_t end_file_offset, | 406 size_t end_file_offset, |
407 AssemblyProgram* program) { | 407 AssemblyProgram* program) { |
408 // Callers don't guarantee start < end | |
409 if (start_file_offset >= end_file_offset) return true; | |
408 | 410 |
409 const uint8* start = OffsetToPointer(start_file_offset); | 411 const size_t len = end_file_offset - start_file_offset; |
Peter Kasting
2014/09/30 00:08:01
Since we know end > start, storing this as a size_
| |
410 const uint8* end = OffsetToPointer(end_file_offset); | |
Peter Kasting
2014/09/30 00:08:01
There's no real gain to converting the offsets to
| |
411 | 412 |
412 // Callers don't guarantee start < end | 413 if (!program->EmitBytesInstruction(OffsetToPointer(start_file_offset), len)) |
413 if (start >= end) return true; | |
414 | |
415 const ptrdiff_t len = end - start; // Works because vars are byte pointers | |
416 | |
417 if (!program->EmitBytesInstruction(start, len)) | |
418 return false; | 414 return false; |
419 | 415 |
420 return true; | 416 return true; |
421 } | 417 } |
422 | 418 |
423 CheckBool DisassemblerElf32::ParseAbs32Relocs() { | 419 CheckBool DisassemblerElf32::ParseAbs32Relocs() { |
424 abs32_locations_.clear(); | 420 abs32_locations_.clear(); |
425 | 421 |
426 // Loop through sections for relocation sections | 422 // Loop through sections for relocation sections |
427 for (int section_id = 0; section_id < SectionHeaderCount(); section_id++) { | 423 for (int section_id = 0; section_id < SectionHeaderCount(); section_id++) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 return false; | 493 return false; |
498 } | 494 } |
499 | 495 |
500 std::sort(rel32_locations_.begin(), | 496 std::sort(rel32_locations_.begin(), |
501 rel32_locations_.end(), | 497 rel32_locations_.end(), |
502 TypedRVA::IsLessThan); | 498 TypedRVA::IsLessThan); |
503 return true; | 499 return true; |
504 } | 500 } |
505 | 501 |
506 } // namespace courgette | 502 } // namespace courgette |
OLD | NEW |