File indexing completed on 2024-05-12 05:43:28

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 ELFDYNAMICENTRY_H
0019 #define ELFDYNAMICENTRY_H
0020 
0021 #include <cstdint>
0022 
0023 class ElfDynamicSection;
0024 
0025 class QString;
0026 
0027 /** Entry in the dynamic section. */
0028 class ElfDynamicEntry
0029 {
0030 public:
0031     ElfDynamicEntry(const ElfDynamicEntry &other) = delete;
0032     virtual ~ElfDynamicEntry();
0033     ElfDynamicEntry& operator=(const ElfDynamicEntry &other) = delete;
0034 
0035     /** The section this entry belongs to. */
0036     const ElfDynamicSection* dynamicSection() const;
0037 
0038     /** Human readable tag name. */
0039     QString tagName() const;
0040 
0041     /** Returns whether value() is an index into the string table. */
0042     bool isStringValue() const;
0043     /** Returns the string value for this entry. */
0044     const char* stringValue() const;
0045 
0046     /** Returns whether the value of this entry is an address (ie. pointer() returns something valid). */
0047     bool isAddress() const;
0048 
0049     virtual int64_t tag() const = 0;
0050     virtual uint64_t value() const = 0;
0051     /** Changes the value for this entry. Note that this actually writes to the file, assuming
0052      *  it's written in write mode.
0053      */
0054     virtual void setValue(uint64_t value) = 0;
0055     virtual uint64_t pointer() const = 0;
0056 
0057 protected:
0058     explicit ElfDynamicEntry(const ElfDynamicSection *section);
0059     const ElfDynamicSection *m_section;
0060 };
0061 
0062 #endif // ELFDYNAMICENTRY_H