File indexing completed on 2024-05-12 05:43:30
0001 /* 0002 Copyright (C) 2015 Volker Krause <vkrause@kde.org> 0003 0004 This program is free software; you can redistribute it and/or modify it 0005 under the terms of the GNU Library General Public License as published by 0006 the Free Software Foundation; either version 2 of the License, or (at your 0007 option) any later version. 0008 0009 This program is distributed in the hope that it will be useful, but WITHOUT 0010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 0012 License for more details. 0013 0014 You should have received a copy of the GNU General Public License 0015 along with this program. If not, see <https://www.gnu.org/licenses/>. 0016 */ 0017 0018 #ifndef ELF_SEGMENTHEADER_IMPL_H 0019 #define ELF_SEGMENTHEADER_IMPL_H 0020 0021 #include "elfsegmentheader.h" 0022 0023 template <typename T> 0024 class ElfSegmentHeaderImpl : public ElfSegmentHeader 0025 { 0026 public: 0027 explicit ElfSegmentHeaderImpl(ElfFile *file, uint16_t segmentIndex) : 0028 ElfSegmentHeader(file), 0029 m_hdr(reinterpret_cast<const T*>(file->rawData() + file->header()->programHeaderTableOffset() + segmentIndex * file->header()->programHeaderEntrySize())) 0030 { 0031 } 0032 0033 ~ElfSegmentHeaderImpl() = default; 0034 0035 uint32_t type() const final override { return m_hdr->p_type; } 0036 uint32_t flags() const final override { return m_hdr->p_flags; } 0037 uint64_t offset() const final override { return m_hdr->p_offset; } 0038 uint64_t virtualAddress() const final override { return m_hdr->p_vaddr; } 0039 uint64_t physicalAddress() const final override { return m_hdr->p_paddr; } 0040 uint64_t fileSize() const final override { return m_hdr->p_filesz; } 0041 uint64_t memorySize() const final override { return m_hdr->p_memsz; } 0042 uint64_t alignment() const final override { return m_hdr->p_align; } 0043 0044 private: 0045 const T* m_hdr = 0; 0046 }; 0047 0048 #endif