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 ELFRELOCATIONENTRY_H 0019 #define ELFRELOCATIONENTRY_H 0020 0021 #include <QtGlobal> 0022 #include <cstdint> 0023 0024 class ElfRelocationSection; 0025 class ElfSymbolTableEntry; 0026 0027 class ElfRelocationEntry 0028 { 0029 public: 0030 ElfRelocationEntry(); 0031 ElfRelocationEntry(const ElfRelocationEntry&); 0032 explicit ElfRelocationEntry(const ElfRelocationSection *section, uint64_t index, bool withAddend); 0033 ~ElfRelocationEntry(); 0034 0035 ElfRelocationEntry& operator=(const ElfRelocationEntry&); 0036 0037 const ElfRelocationSection* relocationTable() const; 0038 0039 uint64_t offset() const; 0040 uint32_t symbolIndex() const; 0041 uint32_t type() const; 0042 uint64_t addend() const; 0043 0044 /** Symbol table entry referenced from this relocation, can be @c nullptr. */ 0045 ElfSymbolTableEntry* symbol() const; 0046 0047 /** Returns the address the relocation actually points too in the end. 0048 * How this is computed depends on the type of relocation and the platform. 0049 */ 0050 uint64_t relocationTarget() const; 0051 0052 private: 0053 template <typename T> const T* entry() const; 0054 bool is64() const; 0055 0056 const ElfRelocationSection *m_section; 0057 uint64_t m_index:63; 0058 uint64_t m_withAddend:1; 0059 }; 0060 0061 Q_DECLARE_TYPEINFO(ElfRelocationEntry, Q_MOVABLE_TYPE); 0062 0063 #endif // ELFRELOCATIONENTRY_H