LLDB mainline
|
#include "ObjectFileELF.h"
#include <algorithm>
#include <cassert>
#include <optional>
#include <unordered_map>
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Progress.h"
#include "lldb/Core/Section.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Host/LZMA.h"
#include "lldb/Symbol/DWARFCallFrameInfo.h"
#include "lldb/Symbol/SymbolContext.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/DataBufferHeap.h"
#include "lldb/Utility/FileSpecList.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RangeMap.h"
#include "lldb/Utility/Status.h"
#include "lldb/Utility/Stream.h"
#include "lldb/Utility/Timer.h"
#include "llvm/ADT/IntervalMap.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/ELF.h"
#include "llvm/Object/Decompressor.h"
#include "llvm/Support/ARMBuildAttributes.h"
#include "llvm/Support/CRC.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/MipsABIFlags.h"
#include "llvm/BinaryFormat/DynamicTags.def"
Go to the source code of this file.
Macros | |
#define | CASE_AND_STREAM(s, def, width) |
#define | _MAKE_OSABI_CASE(x) |
#define | STO_MIPS_ISA (3 << 6) |
#define | STO_MICROMIPS (2 << 6) |
#define | IS_MICROMIPS(ST_OTHER) (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS) |
#define | DYNAMIC_STRINGIFY_ENUM(tag, value) |
#define | DYNAMIC_TAG(n, v) |
#define | AARCH64_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value) |
#define | HEXAGON_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value) |
#define | MIPS_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value) |
#define | PPC_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value) |
#define | PPC64_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value) |
#define | RISCV_DYNAMIC_TAG(name, value) DYNAMIC_STRINGIFY_ENUM(name, value) |
#define | AARCH64_DYNAMIC_TAG(name, value) |
#define | MIPS_DYNAMIC_TAG(name, value) |
#define | HEXAGON_DYNAMIC_TAG(name, value) |
#define | PPC_DYNAMIC_TAG(name, value) |
#define | PPC64_DYNAMIC_TAG(name, value) |
#define | RISCV_DYNAMIC_TAG(name, value) |
#define | DYNAMIC_TAG_MARKER(name, value) |
#define | DYNAMIC_TAG(name, value) |
Functions | |
static user_id_t | SegmentID (size_t PHdrIndex) |
static uint32_t | mipsVariantFromElfFlags (const elf::ELFHeader &header) |
static uint32_t | riscvVariantFromElfFlags (const elf::ELFHeader &header) |
static uint32_t | ppc64VariantFromElfFlags (const elf::ELFHeader &header) |
static uint32_t | loongarchVariantFromElfFlags (const elf::ELFHeader &header) |
static uint32_t | subTypeFromElfHeader (const elf::ELFHeader &header) |
static uint32_t | calc_crc32 (uint32_t init, const DataExtractor &data) |
static const char * | OSABIAsCString (unsigned char osabi_byte) |
static bool | GetOsFromOSABI (unsigned char osabi_byte, llvm::Triple::OSType &ostype) |
static SectionType | GetSectionTypeFromName (llvm::StringRef Name) |
static uint32_t | GetTargetByteSize (SectionType Type, const ArchSpec &arch) |
static Permissions | GetPermissions (const ELFSectionHeader &H) |
static Permissions | GetPermissions (const ELFProgramHeader &H) |
static SectionSP | FindMatchingSection (const SectionList §ion_list, SectionSP section) |
static char | FindArmAarch64MappingSymbol (const char *symbol_name) |
static std::pair< uint64_t, uint64_t > | GetPltEntrySizeAndOffset (const ELFSectionHeader *rel_hdr, const ELFSectionHeader *plt_hdr) |
static unsigned | ParsePLTRelocations (Symtab *symbol_table, user_id_t start_id, unsigned rel_type, const ELFHeader *hdr, const ELFSectionHeader *rel_hdr, const ELFSectionHeader *plt_hdr, const ELFSectionHeader *sym_hdr, const lldb::SectionSP &plt_section_sp, DataExtractor &rel_data, DataExtractor &symtab_data, DataExtractor &strtab_data) |
static void | ApplyELF64ABS64Relocation (Symtab *symtab, ELFRelocation &rel, DataExtractor &debug_data, Section *rel_section) |
static void | ApplyELF64ABS32Relocation (Symtab *symtab, ELFRelocation &rel, DataExtractor &debug_data, Section *rel_section, bool is_signed) |
static void | ApplyELF32ABS32RelRelocation (Symtab *symtab, ELFRelocation &rel, DataExtractor &debug_data, Section *rel_section) |
static std::string | getDynamicTagAsString (uint16_t Arch, uint64_t Type) |
Variables | |
static const char *const | LLDB_NT_OWNER_FREEBSD = "FreeBSD" |
static const char *const | LLDB_NT_OWNER_GNU = "GNU" |
static const char *const | LLDB_NT_OWNER_NETBSD = "NetBSD" |
static const char *const | LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE" |
static const char *const | LLDB_NT_OWNER_OPENBSD = "OpenBSD" |
static const char *const | LLDB_NT_OWNER_ANDROID = "Android" |
static const char *const | LLDB_NT_OWNER_CORE = "CORE" |
static const char *const | LLDB_NT_OWNER_LINUX = "LINUX" |
static const elf_word | LLDB_NT_FREEBSD_ABI_TAG = 0x01 |
static const elf_word | LLDB_NT_FREEBSD_ABI_SIZE = 4 |
static const elf_word | LLDB_NT_GNU_ABI_TAG = 0x01 |
static const elf_word | LLDB_NT_GNU_ABI_SIZE = 16 |
static const elf_word | LLDB_NT_GNU_BUILD_ID_TAG = 0x03 |
static const elf_word | LLDB_NT_NETBSD_IDENT_TAG = 1 |
static const elf_word | LLDB_NT_NETBSD_IDENT_DESCSZ = 4 |
static const elf_word | LLDB_NT_NETBSD_IDENT_NAMESZ = 7 |
static const elf_word | LLDB_NT_NETBSD_PROCINFO = 1 |
static const elf_word | LLDB_NT_GNU_ABI_OS_LINUX = 0x00 |
static const elf_word | LLDB_NT_GNU_ABI_OS_HURD = 0x01 |
static const elf_word | LLDB_NT_GNU_ABI_OS_SOLARIS = 0x02 |
#define _MAKE_OSABI_CASE | ( | x | ) |
#define AARCH64_DYNAMIC_TAG | ( | name, | |
value | |||
) | DYNAMIC_STRINGIFY_ENUM(name, value) |
#define AARCH64_DYNAMIC_TAG | ( | name, | |
value | |||
) |
#define CASE_AND_STREAM | ( | s, | |
def, | |||
width | |||
) |
Definition at line 49 of file ObjectFileELF.cpp.
#define DYNAMIC_STRINGIFY_ENUM | ( | tag, | |
value | |||
) |
#define DYNAMIC_TAG | ( | n, | |
v | |||
) |
#define DYNAMIC_TAG | ( | name, | |
value | |||
) |
#define DYNAMIC_TAG_MARKER | ( | name, | |
value | |||
) |
#define HEXAGON_DYNAMIC_TAG | ( | name, | |
value | |||
) | DYNAMIC_STRINGIFY_ENUM(name, value) |
#define HEXAGON_DYNAMIC_TAG | ( | name, | |
value | |||
) |
#define IS_MICROMIPS | ( | ST_OTHER | ) | (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS) |
Definition at line 2073 of file ObjectFileELF.cpp.
#define MIPS_DYNAMIC_TAG | ( | name, | |
value | |||
) | DYNAMIC_STRINGIFY_ENUM(name, value) |
#define MIPS_DYNAMIC_TAG | ( | name, | |
value | |||
) |
#define PPC64_DYNAMIC_TAG | ( | name, | |
value | |||
) | DYNAMIC_STRINGIFY_ENUM(name, value) |
#define PPC64_DYNAMIC_TAG | ( | name, | |
value | |||
) |
#define PPC_DYNAMIC_TAG | ( | name, | |
value | |||
) | DYNAMIC_STRINGIFY_ENUM(name, value) |
#define PPC_DYNAMIC_TAG | ( | name, | |
value | |||
) |
#define RISCV_DYNAMIC_TAG | ( | name, | |
value | |||
) | DYNAMIC_STRINGIFY_ENUM(name, value) |
#define RISCV_DYNAMIC_TAG | ( | name, | |
value | |||
) |
#define STO_MICROMIPS (2 << 6) |
Definition at line 2072 of file ObjectFileELF.cpp.
#define STO_MIPS_ISA (3 << 6) |
Definition at line 2071 of file ObjectFileELF.cpp.
|
static |
Definition at line 2746 of file ObjectFileELF.cpp.
References lldb_private::Symtab::FindSymbolByID(), lldb_private::Symbol::GetAddressRef(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::ConstString::GetCString(), lldb_private::Address::GetFileAddress(), lldb_private::Section::GetFileOffset(), lldb_private::GetLog(), lldb_private::Symbol::GetName(), lldb_private::DataExtractor::GetSharedDataBuffer(), LLDB_INVALID_ADDRESS, and LLDB_LOGF.
Referenced by ObjectFileELF::ApplyRelocations().
|
static |
Definition at line 2720 of file ObjectFileELF.cpp.
References lldb_private::Symtab::FindSymbolByID(), lldb_private::Symbol::GetAddressRef(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::Address::GetFileAddress(), lldb_private::Section::GetFileOffset(), lldb_private::GetLog(), lldb_private::DataExtractor::GetSharedDataBuffer(), INT32_MAX, LLDB_LOGF, and UINT32_MAX.
Referenced by ObjectFileELF::ApplyRelocations().
|
static |
Definition at line 2702 of file ObjectFileELF.cpp.
References lldb_private::Symtab::FindSymbolByID(), lldb_private::Symbol::GetAddressRef(), lldb_private::WritableDataBuffer::GetBytes(), lldb_private::Address::GetFileAddress(), lldb_private::Section::GetFileOffset(), and lldb_private::DataExtractor::GetSharedDataBuffer().
Referenced by ObjectFileELF::ApplyRelocations().
|
static |
Definition at line 466 of file ObjectFileELF.cpp.
References lldb_private::DataExtractor::GetByteSize(), and lldb_private::DataExtractor::GetDataStart().
Referenced by ObjectFileELF::CalculateELFNotesSegmentsCRC32(), ObjectFileELF::GetModuleSpecifications(), and ObjectFileELF::GetUUID().
|
static |
Definition at line 2058 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::ParseSymbols().
|
static |
Definition at line 1874 of file ObjectFileELF.cpp.
References FindMatchingSection().
Referenced by FindMatchingSection(), and ObjectFileELF::ParseSymbols().
|
static |
Definition at line 3512 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::DumpELFDynamic().
|
static |
Definition at line 532 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::GetModuleSpecifications(), and ObjectFileELF::GetSectionHeaderInfo().
|
static |
Definition at line 1751 of file ObjectFileELF.cpp.
References elf::ELFProgramHeader::p_flags.
|
static |
Definition at line 1740 of file ObjectFileELF.cpp.
References elf::ELFSectionHeader::sh_flags.
Referenced by ObjectFileELF::CreateSections().
|
static |
Definition at line 2534 of file ObjectFileELF.cpp.
References elf::ELFSectionHeader::sh_addralign, elf::ELFSectionHeader::sh_entsize, and elf::ELFSectionHeader::sh_size.
Referenced by ParsePLTRelocations().
|
static |
Definition at line 1656 of file ObjectFileELF.cpp.
References lldb::eSectionTypeARMexidx, lldb::eSectionTypeARMextab, lldb::eSectionTypeCode, lldb::eSectionTypeData, lldb::eSectionTypeDebug, lldb::eSectionTypeDWARFDebugAbbrev, lldb::eSectionTypeDWARFDebugAbbrevDwo, lldb::eSectionTypeDWARFDebugAddr, lldb::eSectionTypeDWARFDebugAranges, lldb::eSectionTypeDWARFDebugCuIndex, lldb::eSectionTypeDWARFDebugFrame, lldb::eSectionTypeDWARFDebugInfo, lldb::eSectionTypeDWARFDebugInfoDwo, lldb::eSectionTypeDWARFDebugLine, lldb::eSectionTypeDWARFDebugLineStr, lldb::eSectionTypeDWARFDebugLoc, lldb::eSectionTypeDWARFDebugLocDwo, lldb::eSectionTypeDWARFDebugLocLists, lldb::eSectionTypeDWARFDebugLocListsDwo, lldb::eSectionTypeDWARFDebugMacInfo, lldb::eSectionTypeDWARFDebugMacro, lldb::eSectionTypeDWARFDebugNames, lldb::eSectionTypeDWARFDebugPubNames, lldb::eSectionTypeDWARFDebugPubTypes, lldb::eSectionTypeDWARFDebugRanges, lldb::eSectionTypeDWARFDebugRngLists, lldb::eSectionTypeDWARFDebugRngListsDwo, lldb::eSectionTypeDWARFDebugStr, lldb::eSectionTypeDWARFDebugStrDwo, lldb::eSectionTypeDWARFDebugStrOffsets, lldb::eSectionTypeDWARFDebugStrOffsetsDwo, lldb::eSectionTypeDWARFDebugTuIndex, lldb::eSectionTypeDWARFDebugTypes, lldb::eSectionTypeDWARFDebugTypesDwo, lldb::eSectionTypeDWARFGNUDebugAltLink, lldb::eSectionTypeEHFrame, lldb::eSectionTypeGoSymtab, lldb::eSectionTypeLLDBFormatters, lldb::eSectionTypeLLDBTypeSummaries, lldb::eSectionTypeOther, and lldb::eSectionTypeSwiftModules.
Referenced by lldb_private::wasm::ObjectFileWasm::CreateSections(), and ObjectFileELF::GetSectionType().
|
static |
Definition at line 1728 of file ObjectFileELF.cpp.
References lldb::eSectionTypeCode, lldb::eSectionTypeData, lldb::eSectionTypeZeroFill, lldb_private::ArchSpec::GetCodeByteSize(), and lldb_private::ArchSpec::GetDataByteSize().
Referenced by ObjectFileELF::CreateSections().
|
static |
Definition at line 325 of file ObjectFileELF.cpp.
References elf::ELFHeader::e_ident, lldb_private::ArchSpec::eLoongArchSubType_loongarch32, lldb_private::ArchSpec::eLoongArchSubType_loongarch64, and lldb_private::ArchSpec::eLoongArchSubType_unknown.
Referenced by subTypeFromElfHeader().
|
static |
Definition at line 252 of file ObjectFileELF.cpp.
References elf::ELFHeader::e_flags, elf::ELFHeader::e_ident, elf::ELFHeader::e_type, lldb_private::ArchSpec::eMIPSSubType_mips32, lldb_private::ArchSpec::eMIPSSubType_mips32el, lldb_private::ArchSpec::eMIPSSubType_mips32r2, lldb_private::ArchSpec::eMIPSSubType_mips32r2el, lldb_private::ArchSpec::eMIPSSubType_mips32r6, lldb_private::ArchSpec::eMIPSSubType_mips32r6el, lldb_private::ArchSpec::eMIPSSubType_mips64, lldb_private::ArchSpec::eMIPSSubType_mips64el, lldb_private::ArchSpec::eMIPSSubType_mips64r2, lldb_private::ArchSpec::eMIPSSubType_mips64r2el, lldb_private::ArchSpec::eMIPSSubType_mips64r6, lldb_private::ArchSpec::eMIPSSubType_mips64r6el, and lldb_private::ArchSpec::eMIPSSubType_unknown.
Referenced by subTypeFromElfHeader().
|
static |
Definition at line 495 of file ObjectFileELF.cpp.
References _MAKE_OSABI_CASE.
Referenced by ObjectFileELF::GetModuleSpecifications().
|
static |
Definition at line 2567 of file ObjectFileELF.cpp.
References lldb_private::Symtab::AddSymbol(), lldb::eSymbolTypeTrampoline, GetPltEntrySizeAndOffset(), elf::ELFHeader::GetRelocationJumpSlotType(), elf::ELFHeader::Is32Bit(), elf::ELFSymbol::Parse(), lldb_private::DataExtractor::PeekCStr(), elf::ELFSectionHeader::sh_entsize, elf::ELFSectionHeader::sh_size, and elf::ELFSymbol::st_name.
Referenced by ObjectFileELF::ParseTrampolineSymbols().
|
static |
Definition at line 317 of file ObjectFileELF.cpp.
References elf::ELFHeader::e_ident, lldb_private::ArchSpec::eCore_ppc64_generic, and lldb_private::ArchSpec::eCore_ppc64le_generic.
Referenced by subTypeFromElfHeader().
|
static |
Definition at line 305 of file ObjectFileELF.cpp.
References elf::ELFHeader::e_ident, lldb_private::ArchSpec::eRISCVSubType_riscv32, lldb_private::ArchSpec::eRISCVSubType_riscv64, and lldb_private::ArchSpec::eRISCVSubType_unknown.
Referenced by subTypeFromElfHeader().
|
static |
Definition at line 217 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::CreateSections(), and ObjectFileELF::GetBaseAddress().
|
static |
Definition at line 337 of file ObjectFileELF.cpp.
References elf::ELFHeader::e_machine, LLDB_INVALID_CPUTYPE, loongarchVariantFromElfFlags(), mipsVariantFromElfFlags(), ppc64VariantFromElfFlags(), and riscvVariantFromElfFlags().
Referenced by ObjectFileELF::GetModuleSpecifications(), and ObjectFileELF::GetSectionHeaderInfo().
|
static |
Definition at line 73 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 72 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 87 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 86 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 88 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 76 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 75 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 78 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 81 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 82 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 80 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 83 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 67 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 68 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 62 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 63 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 69 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 64 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 65 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().
|
static |
Definition at line 66 of file ObjectFileELF.cpp.
Referenced by ObjectFileELF::RefineModuleDetailsFromNote().