#include "ObjectFilePECOFF.h"
#include "PECallFrameInfo.h"
#include "WindowsMiniDump.h"
#include "lldb/Core/Module.h"
#include "lldb/Core/ModuleSpec.h"
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/Section.h"
#include "lldb/Interpreter/OptionValueDictionary.h"
#include "lldb/Interpreter/OptionValueProperties.h"
#include "lldb/Symbol/ObjectFile.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/FileSpec.h"
#include "lldb/Utility/FileSpecList.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/Timer.h"
#include "lldb/Utility/UUID.h"
#include "llvm/BinaryFormat/COFF.h"
#include "llvm/Object/COFFImportFile.h"
#include "llvm/Support/CRC.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatAdapters.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/TargetParser/Host.h"
#include <optional>
#define IMAGE_DOS_SIGNATURE …
#define IMAGE_NT_SIGNATURE …
#define OPT_HEADER_MAGIC_PE32 …
#define OPT_HEADER_MAGIC_PE32_PLUS …
usingnamespacelldb;
usingnamespacelldb_private;
LLDB_PLUGIN_DEFINE(…)
namespace {
static constexpr OptionEnumValueElement g_abi_enums[] = …;
#define LLDB_PROPERTIES_objectfilepecoff
#include "ObjectFilePECOFFProperties.inc"
enum { … };
class PluginProperties : public Properties { … };
}
static PluginProperties &GetGlobalPluginProperties() { … }
static bool GetDebugLinkContents(const llvm::object::COFFObjectFile &coff_obj,
std::string &gnu_debuglink_file,
uint32_t &gnu_debuglink_crc) { … }
static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj) { … }
char ObjectFilePECOFF::ID;
void ObjectFilePECOFF::Initialize() { … }
void ObjectFilePECOFF::DebuggerInitialize(Debugger &debugger) { … }
void ObjectFilePECOFF::Terminate() { … }
llvm::StringRef ObjectFilePECOFF::GetPluginDescriptionStatic() { … }
ObjectFile *ObjectFilePECOFF::CreateInstance(
const lldb::ModuleSP &module_sp, DataBufferSP data_sp,
lldb::offset_t data_offset, const lldb_private::FileSpec *file_p,
lldb::offset_t file_offset, lldb::offset_t length) { … }
ObjectFile *ObjectFilePECOFF::CreateMemoryInstance(
const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
const lldb::ProcessSP &process_sp, lldb::addr_t header_addr) { … }
size_t ObjectFilePECOFF::GetModuleSpecifications(
const lldb_private::FileSpec &file, lldb::DataBufferSP &data_sp,
lldb::offset_t data_offset, lldb::offset_t file_offset,
lldb::offset_t length, lldb_private::ModuleSpecList &specs) { … }
bool ObjectFilePECOFF::SaveCore(const lldb::ProcessSP &process_sp,
lldb_private::SaveCoreOptions &options,
lldb_private::Status &error) { … }
bool ObjectFilePECOFF::MagicBytesMatch(DataBufferSP data_sp) { … }
lldb::SymbolType ObjectFilePECOFF::MapSymbolType(uint16_t coff_symbol_type) { … }
bool ObjectFilePECOFF::CreateBinary() { … }
ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
DataBufferSP data_sp,
lldb::offset_t data_offset,
const FileSpec *file,
lldb::offset_t file_offset,
lldb::offset_t length)
: … { … }
ObjectFilePECOFF::ObjectFilePECOFF(const lldb::ModuleSP &module_sp,
WritableDataBufferSP header_data_sp,
const lldb::ProcessSP &process_sp,
addr_t header_addr)
: … { … }
ObjectFilePECOFF::~ObjectFilePECOFF() = default;
bool ObjectFilePECOFF::ParseHeader() { … }
bool ObjectFilePECOFF::SetLoadAddress(Target &target, addr_t value,
bool value_is_offset) { … }
ByteOrder ObjectFilePECOFF::GetByteOrder() const { … }
bool ObjectFilePECOFF::IsExecutable() const { … }
uint32_t ObjectFilePECOFF::GetAddressByteSize() const { … }
bool ObjectFilePECOFF::NeedsEndianSwap() const { … }
bool ObjectFilePECOFF::ParseDOSHeader(DataExtractor &data,
dos_header_t &dos_header) { … }
bool ObjectFilePECOFF::ParseCOFFHeader(DataExtractor &data,
lldb::offset_t *offset_ptr,
coff_header_t &coff_header) { … }
bool ObjectFilePECOFF::ParseCOFFOptionalHeader(lldb::offset_t *offset_ptr) { … }
uint32_t ObjectFilePECOFF::GetRVA(const Address &addr) const { … }
Address ObjectFilePECOFF::GetAddress(uint32_t rva) { … }
lldb::addr_t ObjectFilePECOFF::GetFileAddress(uint32_t rva) const { … }
DataExtractor ObjectFilePECOFF::ReadImageData(uint32_t offset, size_t size) { … }
DataExtractor ObjectFilePECOFF::ReadImageDataByRVA(uint32_t rva, size_t size) { … }
bool ObjectFilePECOFF::ParseSectionHeaders(
uint32_t section_header_data_offset) { … }
llvm::StringRef ObjectFilePECOFF::GetSectionName(const section_header_t §) { … }
void ObjectFilePECOFF::ParseSymtab(Symtab &symtab) { … }
static bool RVASymbolListCompareRVA(const std::pair<uint32_t, uint32_t> &a,
const std::pair<uint32_t, uint32_t> &b) { … }
void ObjectFilePECOFF::AppendFromCOFFSymbolTable(
SectionList *sect_list, Symtab &symtab,
const ObjectFilePECOFF::rva_symbol_list_t &sorted_exports) { … }
ObjectFilePECOFF::rva_symbol_list_t
ObjectFilePECOFF::AppendFromExportTable(SectionList *sect_list,
Symtab &symtab) { … }
std::unique_ptr<CallFrameInfo> ObjectFilePECOFF::CreateCallFrameInfo() { … }
bool ObjectFilePECOFF::IsStripped() { … }
SectionType ObjectFilePECOFF::GetSectionType(llvm::StringRef sect_name,
const section_header_t §) { … }
size_t ObjectFilePECOFF::GetSectionDataSize(Section *section) { … }
void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) { … }
UUID ObjectFilePECOFF::GetUUID() { … }
std::optional<FileSpec> ObjectFilePECOFF::GetDebugLink() { … }
uint32_t ObjectFilePECOFF::ParseDependentModules() { … }
uint32_t ObjectFilePECOFF::GetDependentModules(FileSpecList &files) { … }
lldb_private::Address ObjectFilePECOFF::GetEntryPointAddress() { … }
Address ObjectFilePECOFF::GetBaseAddress() { … }
void ObjectFilePECOFF::Dump(Stream *s) { … }
void ObjectFilePECOFF::DumpDOSHeader(Stream *s, const dos_header_t &header) { … }
void ObjectFilePECOFF::DumpCOFFHeader(Stream *s, const coff_header_t &header) { … }
void ObjectFilePECOFF::DumpOptCOFFHeader(Stream *s,
const coff_opt_header_t &header) { … }
void ObjectFilePECOFF::DumpSectionHeader(Stream *s,
const section_header_t &sh) { … }
void ObjectFilePECOFF::DumpSectionHeaders(Stream *s) { … }
void ObjectFilePECOFF::DumpDependentModules(lldb_private::Stream *s) { … }
bool ObjectFilePECOFF::IsWindowsSubsystem() { … }
ArchSpec ObjectFilePECOFF::GetArchitecture() { … }
ObjectFile::Type ObjectFilePECOFF::CalculateType() { … }
ObjectFile::Strata ObjectFilePECOFF::CalculateStrata() { … }