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 #include "elfdynamicsection.h" 0019 0020 #include <QByteArray> 0021 #include <QVector> 0022 #include <QList> 0023 0024 #include <elf.h> 0025 0026 ElfDynamicSection::ElfDynamicSection(ElfFile* file, ElfSectionHeader *shdr): ElfArraySection< ElfDynamicEntry >(file, shdr) 0027 { 0028 } 0029 0030 QByteArray ElfDynamicSection::soName() const 0031 { 0032 for (const auto entry : m_entries) { 0033 if (entry->tag() == DT_SONAME) { 0034 const auto str = entry->stringValue(); 0035 return QByteArray::fromRawData(str, strlen(str)); 0036 } 0037 } 0038 return QByteArray(); 0039 } 0040 0041 QVector< QByteArray > ElfDynamicSection::neededLibraries() const 0042 { 0043 return stringList(DT_NEEDED); 0044 } 0045 0046 QVector< QByteArray > ElfDynamicSection::rpaths() const 0047 { 0048 return stringList(DT_RPATH); 0049 } 0050 0051 QVector< QByteArray > ElfDynamicSection::runpaths() const 0052 { 0053 return stringList(DT_RUNPATH); 0054 } 0055 0056 QVector< QByteArray > ElfDynamicSection::stringList(int64_t tag) const 0057 { 0058 QVector<QByteArray> v; 0059 for (const auto entry : m_entries) { 0060 if (entry->tag() == tag) { 0061 const QByteArray s = entry->stringValue(); 0062 foreach (const auto &b, s.split(':')) 0063 v.push_back(b); 0064 } 0065 } 0066 return v; 0067 } 0068 0069 ElfDynamicEntry* ElfDynamicSection::entryWithTag(int64_t type) const 0070 { 0071 for (const auto entry : m_entries) { 0072 if (entry->tag() == type) 0073 return entry; 0074 } 0075 return nullptr; 0076 }