LLDB  mainline
Macros | Functions | Variables
ObjectFileELF.cpp File Reference
#include "ObjectFileELF.h"
#include <algorithm>
#include <cassert>
#include <unordered_map>
#include "lldb/Core/FileSpecList.h"
#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/SectionLoadList.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ArchSpec.h"
#include "lldb/Utility/DataBufferHeap.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 dependency graph for ObjectFileELF.cpp:

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)
 

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 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 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)
 

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
 

Macro Definition Documentation

◆ _MAKE_OSABI_CASE

#define _MAKE_OSABI_CASE (   x)
Value:
case x: \
return #x

◆ CASE_AND_STREAM

#define CASE_AND_STREAM (   s,
  def,
  width 
)
Value:
case def: \
s->Printf("%-*s", width, #def); \
break;

Definition at line 47 of file ObjectFileELF.cpp.

◆ IS_MICROMIPS

#define IS_MICROMIPS (   ST_OTHER)    (((ST_OTHER)&STO_MIPS_ISA) == STO_MICROMIPS)

Definition at line 1981 of file ObjectFileELF.cpp.

◆ STO_MICROMIPS

#define STO_MICROMIPS   (2 << 6)

Definition at line 1980 of file ObjectFileELF.cpp.

◆ STO_MIPS_ISA

#define STO_MIPS_ISA   (3 << 6)

Definition at line 1979 of file ObjectFileELF.cpp.

Function Documentation

◆ calc_crc32()

static uint32_t calc_crc32 ( uint32_t  init,
const DataExtractor data 
)
static

◆ FindArmAarch64MappingSymbol()

static char FindArmAarch64MappingSymbol ( const char *  symbol_name)
static

Definition at line 1966 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::ParseSymbols().

◆ GetOsFromOSABI()

static bool GetOsFromOSABI ( unsigned char  osabi_byte,
llvm::Triple::OSType &  ostype 
)
static

◆ GetPermissions() [1/2]

static Permissions GetPermissions ( const ELFProgramHeader H)
static

Definition at line 1697 of file ObjectFileELF.cpp.

References elf::ELFProgramHeader::p_flags.

◆ GetPermissions() [2/2]

static Permissions GetPermissions ( const ELFSectionHeader H)
static

◆ GetPltEntrySizeAndOffset()

static std::pair<uint64_t, uint64_t> GetPltEntrySizeAndOffset ( const ELFSectionHeader rel_hdr,
const ELFSectionHeader plt_hdr 
)
static

◆ GetSectionTypeFromName()

static SectionType GetSectionTypeFromName ( llvm::StringRef  Name)
static

◆ GetTargetByteSize()

static uint32_t GetTargetByteSize ( SectionType  Type,
const ArchSpec arch 
)
static

◆ mipsVariantFromElfFlags()

static uint32_t mipsVariantFromElfFlags ( const elf::ELFHeader header)
static

◆ OSABIAsCString()

static const char* OSABIAsCString ( unsigned char  osabi_byte)
static

Definition at line 461 of file ObjectFileELF.cpp.

References _MAKE_OSABI_CASE.

Referenced by ObjectFileELF::GetModuleSpecifications().

◆ ParsePLTRelocations()

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

◆ ppc64VariantFromElfFlags()

static uint32_t ppc64VariantFromElfFlags ( const elf::ELFHeader header)
static

Definition at line 313 of file ObjectFileELF.cpp.

References elf::ELFHeader::e_ident.

Referenced by subTypeFromElfHeader().

◆ riscvVariantFromElfFlags()

static uint32_t riscvVariantFromElfFlags ( const elf::ELFHeader header)
static

Definition at line 301 of file ObjectFileELF.cpp.

References elf::ELFHeader::e_ident.

Referenced by subTypeFromElfHeader().

◆ SegmentID()

static user_id_t SegmentID ( size_t  PHdrIndex)
static

◆ subTypeFromElfHeader()

static uint32_t subTypeFromElfHeader ( const elf::ELFHeader header)
static

Variable Documentation

◆ LLDB_NT_FREEBSD_ABI_SIZE

const elf_word LLDB_NT_FREEBSD_ABI_SIZE = 4
static

Definition at line 71 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_FREEBSD_ABI_TAG

const elf_word LLDB_NT_FREEBSD_ABI_TAG = 0x01
static

Definition at line 70 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_GNU_ABI_OS_HURD

const elf_word LLDB_NT_GNU_ABI_OS_HURD = 0x01
static

Definition at line 85 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_GNU_ABI_OS_LINUX

const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00
static

Definition at line 84 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_GNU_ABI_OS_SOLARIS

const elf_word LLDB_NT_GNU_ABI_OS_SOLARIS = 0x02
static

Definition at line 86 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_GNU_ABI_SIZE

const elf_word LLDB_NT_GNU_ABI_SIZE = 16
static

Definition at line 74 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_GNU_ABI_TAG

const elf_word LLDB_NT_GNU_ABI_TAG = 0x01
static

Definition at line 73 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_GNU_BUILD_ID_TAG

const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03
static

Definition at line 76 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_NETBSD_IDENT_DESCSZ

const elf_word LLDB_NT_NETBSD_IDENT_DESCSZ = 4
static

Definition at line 79 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_NETBSD_IDENT_NAMESZ

const elf_word LLDB_NT_NETBSD_IDENT_NAMESZ = 7
static

Definition at line 80 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_NETBSD_IDENT_TAG

const elf_word LLDB_NT_NETBSD_IDENT_TAG = 1
static

Definition at line 78 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_NETBSD_PROCINFO

const elf_word LLDB_NT_NETBSD_PROCINFO = 1
static

Definition at line 81 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_ANDROID

const char* const LLDB_NT_OWNER_ANDROID = "Android"
static

Definition at line 65 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_CORE

const char* const LLDB_NT_OWNER_CORE = "CORE"
static

Definition at line 66 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_FREEBSD

const char* const LLDB_NT_OWNER_FREEBSD = "FreeBSD"
static

Definition at line 60 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_GNU

const char* const LLDB_NT_OWNER_GNU = "GNU"
static

Definition at line 61 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_LINUX

const char* const LLDB_NT_OWNER_LINUX = "LINUX"
static

Definition at line 67 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_NETBSD

const char* const LLDB_NT_OWNER_NETBSD = "NetBSD"
static

Definition at line 62 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_NETBSDCORE

const char* const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE"
static

Definition at line 63 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().

◆ LLDB_NT_OWNER_OPENBSD

const char* const LLDB_NT_OWNER_OPENBSD = "OpenBSD"
static

Definition at line 64 of file ObjectFileELF.cpp.

Referenced by ObjectFileELF::RefineModuleDetailsFromNote().