File indexing completed on 2024-05-12 05:43:28
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 #include "elfgnudebuglinksection.h" 0019 0020 #include <QByteArray> 0021 0022 #include <cassert> 0023 0024 /* 0025 * Format, according to GDB manual: 0026 * - A filename, with any leading directory components removed, followed by a zero byte, 0027 * - zero to three bytes of padding, as needed to reach the next four-byte boundary within the section, and 0028 * - a four-byte CRC checksum, stored in the same endianness used for the executable file itself. 0029 * The checksum is computed on the debugging information file's full contents by the function given below, passing zero as the crc argument. 0030 */ 0031 ElfGnuDebugLinkSection::ElfGnuDebugLinkSection(ElfFile* file, ElfSectionHeader* shdr): ElfSection(file, shdr) 0032 { 0033 assert(shdr->size() > 6); 0034 } 0035 0036 ElfGnuDebugLinkSection::~ElfGnuDebugLinkSection() 0037 { 0038 } 0039 0040 QByteArray ElfGnuDebugLinkSection::fileName() const 0041 { 0042 auto len = strnlen(reinterpret_cast<const char*>(rawData()), header()->size() - 4); 0043 return QByteArray::fromRawData(reinterpret_cast<const char*>(rawData()), len); 0044 } 0045 0046 uint32_t ElfGnuDebugLinkSection::crc() const 0047 { 0048 return *reinterpret_cast<uint32_t*>(rawData() + header()->size() - sizeof(uint32_t)); 0049 }