File indexing completed on 2024-05-12 05:43:30
0001 /* 0002 Copyright (C) 2013-2014 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 ELFSECTIONHEADER_H 0019 #define ELFSECTIONHEADER_H 0020 0021 #include <cstdint> 0022 0023 class ElfFile; 0024 0025 /** Size-independent adapter to ElfXX_Shdr. */ 0026 class ElfSectionHeader 0027 { 0028 public: 0029 ElfSectionHeader(const ElfSectionHeader &other) = delete; 0030 virtual ~ElfSectionHeader(); 0031 ElfSectionHeader& operator=(const ElfSectionHeader &other) = delete; 0032 0033 uint16_t sectionIndex() const; 0034 /** The location of the header (not the section it describes) in the ELF file. */ 0035 uint64_t headerOffset() const; 0036 0037 /** String index of the section name. */ 0038 virtual uint32_t nameIndex() const = 0; 0039 virtual uint32_t type() const = 0; 0040 virtual uint64_t flags() const = 0; 0041 virtual uint64_t virtualAddress() const = 0; 0042 /** The location of the section (not this header) in the ELF file. */ 0043 virtual uint64_t sectionOffset() const = 0; 0044 virtual uint64_t size() const = 0; 0045 virtual uint32_t link() const = 0; 0046 virtual uint32_t info() const = 0; 0047 virtual uint64_t alignment() const = 0; 0048 virtual uint64_t entrySize() const = 0; 0049 0050 /** Section name. */ 0051 const char* name() const; 0052 /** Returns @c true if this section is related to debug information in some way. */ 0053 bool isDebugInformation() const; 0054 0055 /** Returns the amount of entries in this section if section is an array. */ 0056 uint64_t entryCount() const; 0057 0058 ElfFile* file() const; 0059 0060 protected: 0061 explicit ElfSectionHeader(ElfFile *file, uint16_t sectionIndex); 0062 0063 private: 0064 ElfFile *m_file = nullptr; 0065 uint16_t m_sectionIndex = 0; 0066 }; 0067 0068 #endif // ELFSECTIONHEADER_H