Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 Google Inc. | 1 // Copyright (c) 2011 Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 #ifndef NO_STABS_SUPPORT | 88 #ifndef NO_STABS_SUPPORT |
| 89 using google_breakpad::StabsToModule; | 89 using google_breakpad::StabsToModule; |
| 90 #endif | 90 #endif |
| 91 using google_breakpad::scoped_ptr; | 91 using google_breakpad::scoped_ptr; |
| 92 | 92 |
| 93 // Define AARCH64 ELF architecture if host machine does not include this define. | 93 // Define AARCH64 ELF architecture if host machine does not include this define. |
| 94 #ifndef EM_AARCH64 | 94 #ifndef EM_AARCH64 |
| 95 #define EM_AARCH64 183 | 95 #define EM_AARCH64 183 |
| 96 #endif | 96 #endif |
| 97 | 97 |
| 98 // Define SHT_ANDROID_REL and SHT_ANDROID_RELA if not defined by the host. | |
| 99 // Sections with this type contain Android packed relocations. | |
| 100 #ifndef SHT_ANDROID_REL | |
| 101 #define SHT_ANDROID_REL (SHT_LOOS + 1) | |
| 102 #endif | |
| 103 #ifndef SHT_ANDROID_RELA | |
| 104 #define SHT_ANDROID_RELA (SHT_LOOS + 2) | |
| 105 #endif | |
| 106 | |
| 98 // | 107 // |
| 99 // FDWrapper | 108 // FDWrapper |
| 100 // | 109 // |
| 101 // Wrapper class to make sure opened file is closed. | 110 // Wrapper class to make sure opened file is closed. |
| 102 // | 111 // |
| 103 class FDWrapper { | 112 class FDWrapper { |
| 104 public: | 113 public: |
| 105 explicit FDWrapper(int fd) : | 114 explicit FDWrapper(int fd) : |
| 106 fd_(fd) {} | 115 fd_(fd) {} |
| 107 ~FDWrapper() { | 116 ~FDWrapper() { |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 elf_header->e_machine == EM_MIPS ? SHT_MIPS_DWARF : SHT_PROGBITS; | 613 elf_header->e_machine == EM_MIPS ? SHT_MIPS_DWARF : SHT_PROGBITS; |
| 605 const Shdr* sections = | 614 const Shdr* sections = |
| 606 GetOffset<ElfClass, Shdr>(elf_header, elf_header->e_shoff); | 615 GetOffset<ElfClass, Shdr>(elf_header, elf_header->e_shoff); |
| 607 const Shdr* section_names = sections + elf_header->e_shstrndx; | 616 const Shdr* section_names = sections + elf_header->e_shstrndx; |
| 608 const char* names = | 617 const char* names = |
| 609 GetOffset<ElfClass, char>(elf_header, section_names->sh_offset); | 618 GetOffset<ElfClass, char>(elf_header, section_names->sh_offset); |
| 610 const char *names_end = names + section_names->sh_size; | 619 const char *names_end = names + section_names->sh_size; |
| 611 bool found_debug_info_section = false; | 620 bool found_debug_info_section = false; |
| 612 bool found_usable_info = false; | 621 bool found_usable_info = false; |
| 613 | 622 |
| 623 // Reject files that contain Android packed relocations. The pre-packed | |
| 624 // version of the file should be symbolized; the packed version is only | |
| 625 // intended for use on the target system. | |
| 626 bool has_android_packed_relocations = false; | |
| 627 if (FindElfSectionByName<ElfClass>(".rel.dyn", SHT_ANDROID_REL, | |
| 628 sections, names, | |
| 629 names_end, elf_header->e_shnum)) { | |
| 630 fprintf(stderr, "%s: file contains a \".rel.dyn\" section " | |
| 631 "with type SHT_ANDROID_REL\n", obj_file.c_str()); | |
| 632 has_android_packed_relocations = true; | |
| 633 } | |
| 634 if (FindElfSectionByName<ElfClass>(".rela.dyn", SHT_ANDROID_RELA, | |
| 635 sections, names, | |
| 636 names_end, elf_header->e_shnum)) { | |
| 637 fprintf(stderr, "%s: file contains a \".rela.dyn\" section " | |
| 638 "with type SHT_ANDROID_RELA\n", obj_file.c_str()); | |
| 639 has_android_packed_relocations = true; | |
| 640 } | |
| 641 if (has_android_packed_relocations) { | |
| 642 fprintf(stderr, "%s: files containing Android packed relocations " | |
| 643 "may not be symbolized.\n", obj_file.c_str()); | |
|
rmcilroy
2015/06/18 09:42:11
nit - could we just include the error about not be
simonb (inactive)
2015/06/18 10:46:39
Done.
| |
| 644 return false; | |
| 645 } | |
|
rmcilroy
2015/06/18 09:42:11
Should this be #ifdef (__ANDROID__) ? Maybe SHT_LO
simonb (inactive)
2015/06/18 10:46:39
__ANDROID__ is not defined/relevant for host tools
| |
| 646 | |
| 614 if (options.symbol_data != ONLY_CFI) { | 647 if (options.symbol_data != ONLY_CFI) { |
| 615 #ifndef NO_STABS_SUPPORT | 648 #ifndef NO_STABS_SUPPORT |
| 616 // Look for STABS debugging information, and load it if present. | 649 // Look for STABS debugging information, and load it if present. |
| 617 const Shdr* stab_section = | 650 const Shdr* stab_section = |
| 618 FindElfSectionByName<ElfClass>(".stab", SHT_PROGBITS, | 651 FindElfSectionByName<ElfClass>(".stab", SHT_PROGBITS, |
| 619 sections, names, names_end, | 652 sections, names, names_end, |
| 620 elf_header->e_shnum); | 653 elf_header->e_shnum); |
| 621 if (stab_section) { | 654 if (stab_section) { |
| 622 const Shdr* stabstr_section = stab_section->sh_link + sections; | 655 const Shdr* stabstr_section = stab_section->sh_link + sections; |
| 623 if (stabstr_section) { | 656 if (stabstr_section) { |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 MmapWrapper map_wrapper; | 1000 MmapWrapper map_wrapper; |
| 968 void* elf_header = NULL; | 1001 void* elf_header = NULL; |
| 969 if (!LoadELF(obj_file, &map_wrapper, &elf_header)) | 1002 if (!LoadELF(obj_file, &map_wrapper, &elf_header)) |
| 970 return false; | 1003 return false; |
| 971 | 1004 |
| 972 return ReadSymbolDataInternal(reinterpret_cast<uint8_t*>(elf_header), | 1005 return ReadSymbolDataInternal(reinterpret_cast<uint8_t*>(elf_header), |
| 973 obj_file, debug_dirs, options, module); | 1006 obj_file, debug_dirs, options, module); |
| 974 } | 1007 } |
| 975 | 1008 |
| 976 } // namespace google_breakpad | 1009 } // namespace google_breakpad |
| OLD | NEW |