| 2637 | |
| 2638 | |
| 2639 | string ElfView::ReadStringTable(BinaryReader& reader, const Elf64SectionHeader& section, uint64_t offset) |
| 2640 | { |
| 2641 | if (offset == 0 || offset > section.size) |
| 2642 | return ""; |
| 2643 | |
| 2644 | auto itr = m_stringTableCache.find(section.offset); |
| 2645 | if (itr == m_stringTableCache.end()) |
| 2646 | { |
| 2647 | if (section.size > GetParentView()->GetLength()) |
| 2648 | { |
| 2649 | m_logger->LogError("Unable to read string table with section offset: 0x%" PRIx64 " size: 0x%" PRIx64, section.offset, section.size); |
| 2650 | return ""; |
| 2651 | } |
| 2652 | |
| 2653 | std::vector<char>& tableCache = m_stringTableCache[section.offset]; |
| 2654 | tableCache.resize(section.size); |
| 2655 | reader.Seek(section.offset); |
| 2656 | reader.Read(tableCache.data(), section.size); |
| 2657 | itr = m_stringTableCache.find(section.offset); |
| 2658 | } |
| 2659 | |
| 2660 | const std::vector<char>& tableCache = itr->second; |
| 2661 | return std::string(&tableCache[offset], strlen(tableCache.data() + offset)); |
| 2662 | } |
| 2663 | |
| 2664 | |
| 2665 | // http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi-1.9.html#FUNC-DES |