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 <iterator> | 8 #include <iterator> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 found_rel32 = true; | 598 found_rel32 = true; |
599 if (!ParseRel32RelocsFromSection(section_header)) | 599 if (!ParseRel32RelocsFromSection(section_header)) |
600 return false; | 600 return false; |
601 } | 601 } |
602 if (!found_rel32) | 602 if (!found_rel32) |
603 VLOG(1) << "Warning: Found no rel32 addresses. Missing .text section?"; | 603 VLOG(1) << "Warning: Found no rel32 addresses. Missing .text section?"; |
604 | 604 |
605 return true; | 605 return true; |
606 } | 606 } |
607 | 607 |
| 608 bool DisassemblerElf32::QuickDetects(const uint8_t* start, |
| 609 size_t length, |
| 610 e_machine_values elf_em) { |
| 611 if (length < sizeof(Elf32_Ehdr)) |
| 612 return false; |
| 613 |
| 614 const Elf32_Ehdr* header = reinterpret_cast<const Elf32_Ehdr*>(start); |
| 615 |
| 616 // Have magic for ELF header? |
| 617 if (header->e_ident[0] != 0x7f || header->e_ident[1] != 'E' || |
| 618 header->e_ident[2] != 'L' || header->e_ident[3] != 'F') |
| 619 return false; |
| 620 |
| 621 if (header->e_type != ET_EXEC && header->e_type != ET_DYN) |
| 622 return false; |
| 623 if (header->e_machine != elf_em) |
| 624 return false; |
| 625 if (header->e_version != 1) |
| 626 return false; |
| 627 if (header->e_shentsize != sizeof(Elf32_Shdr)) |
| 628 return false; |
| 629 |
| 630 return true; |
| 631 } |
| 632 |
608 } // namespace courgette | 633 } // namespace courgette |
OLD | NEW |